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
Bug report
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:Your environment
python3-3.11.0-1.fc37.x86_64
Linked PRs