python / python/cpython

Publicly expose `shutil.ReadError` and `shutil.RegistryError`

Offen
#148,001 0 Kommentare 1 Reaktion 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

stdlib type-feature
Vorherrschende Sprache
Python
Sterne
77.2k
Forks
35.9k
PR-Merge-Kennzahlen
PR-Kennzahlen ausstehend

Beschreibung

Bug report
Bug description

shutil.ReadError and shutil.RegistryError are not included in shutil.__all__, making them inaccessible via wildcard import. Both exceptions are actively raised by public API functions:

  • ReadError is raised by unpack_archive()
  • RegistryError is raised by register_unpack_format()

The other shutil exceptions (Error, SameFileError, SpecialFileError) are all in __all__.

>>> from shutil import *
>>> try:
...     unpack_archive("nonexistent.zip")
... except ReadError:
...     pass
...
NameError: name 'ReadError' is not defined. Did you mean: 'KeyError'?
Impact
  • from shutil import * does not export ReadError or RegistryError, so users cannot catch exceptions raised by unpack_archive() or register_unpack_format() without explicitly importing them by name.
  • Neither exception is documented in Doc/library/shutil.rst, while the other three shutil exceptions (Error, SameFileError, SpecialFileError) all have dedicated .. exception:: entries.
  • Tools that rely on __all__ for API discovery (linters, IDE autocompletion, documentation generators) will not surface these exceptions.

This was introduced in commit 6ac91723bd7 (bpo-8295, 2010) which added the archive functions and exceptions but did not add ReadError or RegistryError to __all__. A later fix for incomplete __all__ (#66855, 2014) added SameFileError but missed these two.

Verified on Python 3.14.3 in a clean venv.

Proposed fix

Add "ReadError" and "RegistryError" to __all__ in Lib/shutil.py, and add .. exception:: entries in Doc/library/shutil.rst to document them alongside the other exceptions.

CPython versions tested on:

3.14

Operating system:

All

Linked PRs
  • gh-148004

Beitragsleitfaden

Beitragsleitfaden öffnen

Erste Schritte

  1. Lies das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreib ins Issue, dass du es übernimmst — das erspart doppelte Arbeit.
  3. Forke das Repository und arbeite in einem Branch.
  4. Öffne einen Pull Request, der die Issue-Nummer nennt.

Rechercherichtung

Überprüfe all in Lib/shutil.py und die Ausnahmeeinträge in Doc/library/shutil.rst und sieh dir anschließend den verknüpften PR gh-148004 an, bevor du beginnst. Verifiziere, dass beide Ausnahmen durch einen Wildcard-Import verfügbar gemacht und zusammen mit den anderen shutil-Ausnahmen dokumentiert werden.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
api, documentation
Issue-Typ
Bug
Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Aktivitätsstatus
Veraltet
Klarheit
Klar beschrieben
Anfängerfreundlichkeit
30/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.