Kaydet (Commit) c5342708 authored tarafından Antoine Pitrou's avatar Antoine Pitrou

fix ZipFile.testzip() to work with very large embedded files

üst 7f30a684
...@@ -807,9 +807,14 @@ class ZipFile: ...@@ -807,9 +807,14 @@ class ZipFile:
def testzip(self): def testzip(self):
"""Read all the files and check the CRC.""" """Read all the files and check the CRC."""
chunk_size = 2 ** 20
for zinfo in self.filelist: for zinfo in self.filelist:
try: 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: except BadZipfile:
return zinfo.filename return zinfo.filename
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment