mirror of
https://github.com/python/cpython.git
synced 2025-07-28 21:55:21 +00:00
fix ZipFile.testzip() to work with very large embedded files
This commit is contained in:
parent
7f30a684c6
commit
c53427087e
1 changed files with 6 additions and 1 deletions
|
@ -807,9 +807,14 @@ class ZipFile:
|
|||
|
||||
def testzip(self):
|
||||
"""Read all the files and check the CRC."""
|
||||
chunk_size = 2 ** 20
|
||||
for zinfo in self.filelist:
|
||||
try:
|
||||
self.read(zinfo.filename) # Check CRC-32
|
||||
# Read by chunks, to avoid an OverflowError or a
|
||||
# MemoryError with very large embedded files.
|
||||
f = self.open(zinfo.filename, "r")
|
||||
while f.read(chunk_size): # Check CRC-32
|
||||
pass
|
||||
except BadZipfile:
|
||||
return zinfo.filename
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue