[Python-checkins] gh-89668: Optimize ZipFile file header processing algorithm to avoid unneeded IO(gh-25966)

corona10 webhook-mailer at python.org
Sun May 15 10:49:29 EDT 2022


https://github.com/python/cpython/commit/26a162baef96d78656e189b2fa16fdcab7195730
commit: 26a162baef96d78656e189b2fa16fdcab7195730
branch: main
author: Jan Wolski <jan at wolski.fi>
committer: corona10 <donghee.na92 at gmail.com>
date: 2022-05-15T23:49:19+09:00
summary:

gh-89668: Optimize ZipFile file header processing algorithm to avoid unneeded IO(gh-25966)

files:
M Lib/zipfile.py

diff --git a/Lib/zipfile.py b/Lib/zipfile.py
index dc02011084329..9f4437526c91f 100644
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -1564,7 +1564,7 @@ def open(self, name, mode="r", pwd=None, *, force_zip64=False):
 
             fname = zef_file.read(fheader[_FH_FILENAME_LENGTH])
             if fheader[_FH_EXTRA_FIELD_LENGTH]:
-                zef_file.read(fheader[_FH_EXTRA_FIELD_LENGTH])
+                zef_file.seek(fheader[_FH_EXTRA_FIELD_LENGTH], whence=1)
 
             if zinfo.flag_bits & _MASK_COMPRESSED_PATCH:
                 # Zip 2.7: compressed patched data



More information about the Python-checkins mailing list