← 返回首页
[3.8] bpo-36260: Add pitfalls to zipfile module documentation (GH-13378) by miss-islington · Pull Request #15976 · python/cpython · GitHub
Skip to content

Navigation Menu

Toggle navigation
Sign in
Appearance settings
Search or jump to...

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Include my email address so I can be contacted

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Resetting focus
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (2) All 1 file type selected Viewed files
Conversations
Failed to load comments. Retry
Loading
Jump to
Jump to file
Failed to load files. Retry
Loading
Diff view
Unified
Split
Hide whitespace
Apply and reload
Show whitespace
Diff view
Unified
Split
Hide whitespace
Apply and reload
40 changes: 40 additions & 0 deletions Doc/library/zipfile.rst
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -816,5 +816,45 @@ Command-line options

Test whether the zipfile is valid or not.

Decompression pitfalls
----------------------

The extraction in zipfile module might fail due to some pitfalls listed below.

From file itself
~~~~~~~~~~~~~~~~

Decompression may fail due to incorrect password / CRC checksum / ZIP format or
unsupported compression method / decryption.

File System limitations
~~~~~~~~~~~~~~~~~~~~~~~

Exceeding limitations on different file systems can cause decompression failed.
Such as allowable characters in the directory entries, length of the file name,
length of the pathname, size of a single file, and number of files, etc.

Resources limitations
~~~~~~~~~~~~~~~~~~~~~

The lack of memory or disk volume would lead to decompression
failed. For example, decompression bombs (aka `ZIP bomb`_)
apply to zipfile library that can cause disk volume exhaustion.

Interruption
~~~~~~~~~~~~

Interruption during the decompression, such as pressing control-C or killing the
decompression process may result in incomplete decompression of the archive.

Default behaviors of extraction
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Not knowing the default extraction behaviors
can cause unexpected decompression results.
For example, when extracting the same archive twice,
it overwrites files without asking.


.. _ZIP bomb: https://en.wikipedia.org/wiki/Zip_bomb
.. _PKZIP Application Note: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT
Show comments View file Edit file Delete file Open in desktop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add decompression pitfalls to zipfile module documentation.
Toggle all file notes Toggle all file annotations

Footer

© 2026 GitHub, Inc.