[Python-checkins] cpython (merge 3.6 -> default): Issue #29094: Offsets in a ZIP file created with extern file object and modes

serhiy.storchaka python-checkins at python.org
Sun Jan 1 18:43:23 EST 2017


https://hg.python.org/cpython/rev/a80c14ace927
changeset:   105921:a80c14ace927
parent:      105916:ad06f9acff92
parent:      105920:f36f9bce997d
user:        Serhiy Storchaka <storchaka at gmail.com>
date:        Mon Jan 02 01:43:02 2017 +0200
summary:
  Issue #29094: Offsets in a ZIP file created with extern file object and modes
"w" and "x" now are relative to the start of the file.

files:
  Lib/zipfile.py |  5 +++--
  Misc/NEWS      |  3 +++
  2 files changed, 6 insertions(+), 2 deletions(-)


diff --git a/Lib/zipfile.py b/Lib/zipfile.py
--- a/Lib/zipfile.py
+++ b/Lib/zipfile.py
@@ -1101,11 +1101,12 @@
                 # set the modified flag so central directory gets written
                 # even if no files are added to the archive
                 self._didModify = True
+                self._start_disk = 0
                 try:
-                    self.start_dir = self._start_disk = self.fp.tell()
+                    self.start_dir = self.fp.tell()
                 except (AttributeError, OSError):
                     self.fp = _Tellable(self.fp)
-                    self.start_dir = self._start_disk = 0
+                    self.start_dir = 0
                     self._seekable = False
                 else:
                     # Some file-like objects can provide tell() but not seek()
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -208,6 +208,9 @@
 Library
 -------
 
+- Issue #29094: Offsets in a ZIP file created with extern file object and modes
+  "w" and "x" now are relative to the start of the file.
+
 - Issue #29079: Prevent infinite loop in pathlib.resolve() on Windows
 
 - Issue #13051: Fixed recursion errors in large or resized

-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list