Publicly expose `shutil.ReadError` and `shutil.RegistryError`
Ninguém assumiu esta issue ainda.
- Linguagem predominante
- Python
- Estrelas
- 77.2k
- Forks
- 35.9k
- Métricas de merge de PRs
- Métricas de PR pendentes
Descrição
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
Guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Direção de pesquisa
Inspecione all em Lib/shutil.py e as entradas de exceção em Doc/library/shutil.rst; em seguida, revise o PR vinculado gh-148004 antes de começar. Verifique se ambas as exceções são expostas por uma importação curinga e documentadas junto com as outras exceções de shutil.
Escrita pelo modelo de indexação a partir do texto da issue.
Avaliação
- Stack de tecnologia
- python
- Domínio
- api, documentation
- Tipo de issue
- Bug
- Dificuldade
- 2/5
- Tempo estimado
- 1-3 horas
- Status de atividade
- Estagnada
- Clareza
- Claramente especificada
- Facilidade para iniciantes
- 30/100