Issue 11981: dupe self.fp.tell() in zipfile.ZipFile.writestr (original) (raw)

Created on 2011-05-02 16:36 by proppy, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
zipfile-fix-dupe-fp-tell.patch proppy,2011-05-03 13:39 patch review
zinfo.header_offset.log proppy,2011-05-05 12:41
Messages (9)
msg134990 - (view) Author: Johan Euphrosine (proppy) Date: 2011-05-02 16:36
See: http://hg.python.org/cpython/file/2e3346fc880f/Lib/zipfile.py#l1168 http://hg.python.org/cpython/file/2e3346fc880f/Lib/zipfile.py#l1182
msg135188 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-05-05 11:36
Can you prove that the second one is useless (did it cause you any problem or did you just find it reading the source)? There might be reasons why there are two calls to fp.tell() (e.g. the result is different in the two places and/or zinfo.header_offset is read/changed somewhere else between the two calls).
msg135192 - (view) Author: Johan Euphrosine (proppy) Date: 2011-05-05 12:11
I just find it while reading the source, for fixing #11980 zinfo.header_offset is only read in self._write_check, and it seems to me that no file operation are performed on self.fp between the two call. So I can't see see how it could different. Also the tests suite still pass after removing the second one :) Let me know if you want me to do more investigation.
msg135194 - (view) Author: Johan Euphrosine (proppy) Date: 2011-05-05 12:41
Here is a log that shows zinfo.header_offset value after each .tell() when running test_zipfile
msg135960 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-05-14 06:56
I double checked the code on py3k and I think the second occurrence can be removed.
msg143970 - (view) Author: Alan McIntyre (alanmcintyre) * (Python committer) Date: 2011-09-13 14:06
I also can't see any file operations that might occur between the two .tell() calls, and a full test pass (including test_zipfile64) on the py3k development branch doesn't turn up any problems on Linux (2.6.38, x86_64) for me, so I agree the second .tell() could be removed.
msg175398 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2012-11-11 21:56
LGTM.
msg175772 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2012-11-17 16:56
New changeset d51665f9a416 by Ezio Melotti in branch 'default': #11981: remove duplicate line. Patch by Johan Euphrosine. http://hg.python.org/cpython/rev/d51665f9a416
msg175773 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2012-11-17 16:57
Fixed, thanks for the patch!
History
Date User Action Args
2022-04-11 14:57:16 admin set github: 56190
2012-11-17 16:57:00 ezio.melotti set status: open -> closedversions: - Python 3.3messages: + assignee: ezio.melottiresolution: fixedstage: commit review -> resolved
2012-11-17 16:56:26 python-dev set nosy: + python-devmessages: +
2012-11-11 21:56:21 serhiy.storchaka set stage: commit reviewmessages: + versions: + Python 3.4
2012-04-07 17:57:55 serhiy.storchaka set nosy: + serhiy.storchaka
2011-09-13 14:06:45 alanmcintyre set messages: +
2011-05-14 06:56:29 ezio.melotti set nosy: + alanmcintyremessages: + versions: + Python 3.3, - Python 3.4
2011-05-05 12:41:53 proppy set files: + zinfo.header_offset.logmessages: +
2011-05-05 12:11:43 proppy set messages: +
2011-05-05 11:36:41 ezio.melotti set nosy: + ezio.melottimessages: +
2011-05-03 13:39:06 proppy set files: + zipfile-fix-dupe-fp-tell.patchkeywords: + patchtitle: duplicated self.fp.tell() in zipfile.ZipFile.writestr -> dupe self.fp.tell() in zipfile.ZipFile.writestr
2011-05-02 16:37:17 proppy set type: performancecomponents: + Library (Lib)
2011-05-02 16:36:57 proppy create