Skip to content

Commit 34cba33

Browse files
Issue python#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.
1 parent b47913f commit 34cba33

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

Lib/zipfile.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -1028,11 +1028,12 @@ def __init__(self, file, mode="r", compression=ZIP_STORED, allowZip64=True):
10281028
# set the modified flag so central directory gets written
10291029
# even if no files are added to the archive
10301030
self._didModify = True
1031+
self._start_disk = 0
10311032
try:
1032-
self.start_dir = self._start_disk = self.fp.tell()
1033+
self.start_dir = self.fp.tell()
10331034
except (AttributeError, OSError):
10341035
self.fp = _Tellable(self.fp)
1035-
self.start_dir = self._start_disk = 0
1036+
self.start_dir = 0
10361037
self._seekable = False
10371038
else:
10381039
# Some file-like objects can provide tell() but not seek()

Misc/NEWS

+3
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,9 @@ Core and Builtins
140140
Library
141141
-------
142142

143+
- Issue #29094: Offsets in a ZIP file created with extern file object and modes
144+
"w" and "x" now are relative to the start of the file.
145+
143146
- Issue #13051: Fixed recursion errors in large or resized
144147
curses.textpad.Textbox. Based on patch by Tycho Andersen.
145148

0 commit comments

Comments
 (0)