python / python/cpython

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

Đang mở
#148,001 0 bình luận 1 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

stdlib type-feature
Ngôn ngữ chính
Python
Star
77.2k
Fork
35.9k
Chỉ số merge pull request
Chỉ số pull request đang chờ

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Hướng nghiên cứu

Kiểm tra all trong Lib/shutil.py và các mục ngoại lệ trong Doc/library/shutil.rst, sau đó xem xét PR được liên kết gh-148004 trước khi bắt đầu. Xác minh rằng cả hai ngoại lệ đều được cung cấp thông qua wildcard import và được ghi lại cùng với các ngoại lệ shutil khác.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Đánh giá

Công nghệ
python
Lĩnh vực
api, documentation
Loại issue
Lỗi
Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức độ hoạt động
Đình trệ
Độ rõ ràng
Đặc tả rõ ràng
Mức phù hợp với người mới
30/100

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.