Publicly expose `shutil.ReadError` and `shutil.RegistryError`
Nadie ha tomado este issue todavía.
- Lenguaje dominante
- Python
- Estrellas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PR
- Métricas de PR pendientes
Descripción
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:
ReadErroris raised byunpack_archive()RegistryErroris raised byregister_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 exportReadErrororRegistryError, so users cannot catch exceptions raised byunpack_archive()orregister_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
Guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Línea de trabajo
Inspecciona all en Lib/shutil.py y las entradas de excepciones en Doc/library/shutil.rst; después, revisa el PR vinculado gh-148004 antes de empezar. Verifica que ambas excepciones estén expuestas mediante una importación comodín y documentadas junto con las demás excepciones de shutil.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- python
- Área
- api, documentation
- Tipo de issue
- Error
- Dificultad
- 2/5
- Tiempo estimado
- 1-3 horas
- Estado de actividad
- Estancado
- Claridad
- Bien especificado
- Aptitud para principiantes
- 30/100