]> granicus.if.org Git - python/commitdiff
Issue #29094: Offsets in a ZIP file created with extern file object and modes
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 1 Jan 2017 17:00:30 +0000 (19:00 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 1 Jan 2017 17:00:30 +0000 (19:00 +0200)
"w" and "x" now are relative to the start of the file.

Lib/zipfile.py
Misc/NEWS

index 2476717c963a8314133b3c38c9c5e35ef3c0648d..048f60a708e0928d78881b5126c0bd7c06b935c7 100644 (file)
@@ -1028,11 +1028,12 @@ class ZipFile:
                 # 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()
index 0dd4ef10f5d7e4b1d4546a079bb66993a855f32b..ad67b1da62e63dc600843ca68e797b5a74413b50 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -140,6 +140,9 @@ Core and Builtins
 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 #13051: Fixed recursion errors in large or resized
   curses.textpad.Textbox.  Based on patch by Tycho Andersen.