On this page
zipfile.BadZipFile
Up: zipfile | Next: zipfile.BadZipfile
Rel: zipfile.BadZipfile, zipfile.error, zipfile.is_zipfile, zipfile.LargeZipFile
Ref: docs.python.org โ zipfile.BadZipFile
Tags: #public #python3 #stdlib #zipfile
Import
import zipfile
from zipfile import BadZipFile
Signature & Overview
zipfile.BadZipFile(...)
zipfile.BadZipFile class.
Methods & Attributes
BadZipFile.add_note(self, note, /)โ Add a note to the exceptionBadZipFile.with_traceback(self, tb, /)โ Set self.traceback to tb and return self.
Usage
import io
import zipfile
try:
with zipfile.ZipFile(io.BytesIO(b"not a zip archive")):
pass
except zipfile.BadZipFile:
assert True
Gotchas
- Raised for corrupt, truncated, or non-zip files: Catch
zipfile.BadZipFilewhenever opening user-supplied archives.
REPL Inspect
from zipfile import BadZipFile
help(BadZipFile)
Linked from
- tuts/python3/stdlib_module/zipfile
- tuts/python3/stdlib_module/zipfile/BadZipfile_class
- tuts/python3/stdlib_module/zipfile/error
- tuts/python3/stdlib_module/zipfile/is_zipfile
- tuts/python3/stdlib_module/zipfile/LargeZipFile
- tuts/python3/stdlib_module/zipfile/Path
- tuts/python3/stdlib_module/zipfile/PyZipFile
- tuts/python3/stdlib_module/zipfile/ZipFile
- tuts/python3/stdlib_module/zipfile/ZipInfo
Related notes
- tuts/python3/stdlib_module/zipfile/BadZipfile_class Linked here; links to this page; shared tags: #stdlib, #zipfile
- tuts/python3/stdlib_module/zipfile/error Linked here; links to this page; shared tags: #stdlib, #zipfile
- tuts/python3/stdlib_module/zipfile/is_zipfile Linked here; links to this page; shared tags: #stdlib, #zipfile
- tuts/python3/stdlib_module/zipfile/LargeZipFile Linked here; links to this page; shared tags: #stdlib, #zipfile
- tuts/python3/stdlib_module/zipfile/ZipFile Linked here; links to this page; shared tags: #stdlib, #zipfile
- tuts/python3/stdlib_module/zipfile/Path links to this page; shared tags: #stdlib, #zipfile
- tuts/python3/stdlib_module/zipfile/PyZipFile links to this page; shared tags: #stdlib, #zipfile
- tuts/python3/stdlib_module/zipfile/ZipInfo links to this page; shared tags: #stdlib, #zipfile
- tuts/python3/stdlib_module/zipfile links to this page; shared tags: #stdlib
- tuts/c/stdlib shared tags: #stdlib