Python Glossary Русский

all Python 3Exceptionsexception

shutil.ReadError

module exceptions

Raised when an archive cannot be read

Syntax

raise shutil.ReadError

unpack_archive picks an unpacker by the file name extension, never by content, so a perfectly valid zip renamed to data.bin fails with ReadError about an unknown format. When the extension is non-standard, pass format explicitly ('zip', 'gztar' and so on) to skip the guessing step. The same error also comes from the zip and tar unpackers themselves when the extension matched but the bytes are not an archive.

Examples

import shutil
try:
    raise shutil.ReadError
except shutil.ReadError as e:
    print(type(e).__name__)   # → ReadError

See also

Open in the full glossarydocs.python.orgReport an inaccuracy