python / python/cpython

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

オープン
#148,001 コメント 0 件 リアクション 1 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

stdlib type-feature
主要言語
Python
スター
77.2k
フォーク
35.9k
PR マージ指標
PR 指標を取得中

説明

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

コントリビューションガイド

コントリビューションガイドを開く

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

開始する前に、Lib/shutil.py の all と Doc/library/shutil.rst の例外エントリを確認し、リンクされた PR gh-148004 をレビューしてください。両方の例外がワイルドカードインポートで公開され、他の shutil 例外と併せてドキュメント化されていることを確認してください。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
python
領域
api, documentation
issue の種類
バグ
難易度
2/5
見積もり時間
1〜3時間
活発さ
停滞
明瞭さ
明確に書かれている
初心者へのやさしさ
30/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。