shutil.unpack_archive returns bogus ReadError exceptions when input is not found or inaccessible
オープン
まだ誰も着手していません。
stdlib
type-bug
- 主要言語
- Python
- スター
- 77.2k
- フォーク
- 36k
- PR マージ指標
- PR 指標を取得中
説明
Bug report
$ python -c 'import shutil; shutil.unpack_archive("./enoent")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.11/shutil.py", line 1311, in unpack_archive
raise ReadError("Unknown archive format '{0}'".format(filename))
shutil.ReadError: Unknown archive format './enoent'
$ python -c 'import shutil; shutil.unpack_archive("/root/inaccessible")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib64/python3.11/shutil.py", line 1311, in unpack_archive
raise ReadError("Unknown archive format '{0}'".format(filename))
shutil.ReadError: Unknown archive format '/root/inaccessible'
The generic exception makes it handle to handle the error programatically, and the message is also very confusing to the user. Instead, the function should just propagate the detailed exception it got internally. Compare with open:
$ python -c 'open("./enoent")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
FileNotFoundError: [Errno 2] No such file or directory: './enoent'
$ python -c 'open("/root/inaccessible")'
Traceback (most recent call last):
File "<string>", line 1, in <module>
PermissionError: [Errno 13] Permission denied: '/root/inaccessible'
Your environment
python3-3.11.0-1.fc37.x86_64
Linked PRs
- gh-155587
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
調査の方向性
shutil.py の 1311 行付近から始め、レポートに示されている欠落ファイルとアクセスできないパスのコマンドを再現します。既存の unpack_archive の動作と、存在する場合は関連するテストを確認します。完了条件は、これらの入力が汎用的な ReadError ではなく、詳細なファイルシステム例外を公開することです。
索引モデルが issue の本文から書いたものです。
評価
- 技術スタック
- python
- 領域
- backend
- issue の種類
- バグ
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 活発さ
- 停滞
- 明瞭さ
- 明確に書かれている
- 初心者へのやさしさ
- 25/100