This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ZipFile writes incorrect modification time (second is off-by-one)
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.0, Python 2.4, Python 2.6, Python 2.5
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: Nosy List: ctheune, rhettinger
Priority: normal Keywords:

Created on 2009-03-09 09:38 by ctheune, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
zipbug.py ctheune, 2009-03-09 09:38
Messages (2)
msg83364 - (view) Author: Christian Theune (ctheune) * Date: 2009-03-09 09:38
See the attached unit test. On seconds that are > 0 and < 60 the written
second is reduced by 1.

(The test doesn't explicitly prove that this happens during writing, but
we checked this manually. The read function is fine.)
msg83366 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2009-03-09 10:15
This appears to be an intrinsic limitation built into a zipfile's
standard file header format.  The header conforms to
http://www.pkware.com/documents/casestudies/APPNOTE.TXT where the date
and time fields are specified to be stored in the MS-DOS standard
date/time format detailed at
http://www.vsft.com/hal/dostime.htm.  In that format, there are only
five bits allocated for seconds.  Accordingly, seconds are stored
without their least significant bit (see the first few lines of
Zipfile.Fileheader where the seconds are encoded with dt[5] // 2).  Upon
decoding, the seconds are scaled back up (see the _RealGetContents()
method where the decoding is (t&0x1F) * 2).

Since zipfiles are supposed to be cross-platform and the file-format is
fixed, I don't see a way to remove this restriction.  Recommending to
close as wont-fix.
History
Date User Action Args
2022-04-11 14:56:46adminsetgithub: 49707
2009-03-09 22:58:33loewissetstatus: open -> closed
resolution: wont fix
2009-03-09 10:15:35rhettingersetnosy: + rhettinger
messages: + msg83366
2009-03-09 09:38:28ctheunecreate