[ python-Bugs-1698398 ] wrong % of params for format string in ZipFile.printdir()

SourceForge.net noreply at sourceforge.net
Wed Apr 11 15:34:53 CEST 2007


Bugs item #1698398, was opened at 2007-04-11 07:58
Message generated for change (Comment added) made by alanmcintyre
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1698398&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Szabolcs Berecz (szabihernyo)
Assigned to: Nobody/Anonymous (nobody)
Summary: wrong % of params for format string in ZipFile.printdir()

Initial Comment:
In zipfile.py:448
date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time
should be changed to
date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time[:6]

checked with python2.[45] on windows and linux


>>> from zipfile import ZipFile
>>> from StringIO import StringIO
>>> s = StringIO()
>>> zf = ZipFile(s, 'w')
>>> zf.writestr('file.ext', '123')
>>> zf.printdir()
File Name                                             Modified             Size
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.5/zipfile.py", line 448, in printdir
    date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time
TypeError: int argument required
>>> zf.filelist[0].date_time
(2007, 4, 11, 13, 38, 58, 2, 101, 1)
>>>


----------------------------------------------------------------------

Comment By: Alan McIntyre (alanmcintyre)
Date: 2007-04-11 08:34

Message:
Logged In: YES 
user_id=1115903
Originator: NO

The same problem appears to be present in 2.6 as well.  The date_time
attribute of ZipInfo is a time.struct_time in 2.4 and 2.6 (I don't have 2.5
available to check at the moment), not a tuple.  I'm assuming this could be
fixed by changing that line to:

date = "%d-%02d-%02d %02d:%02d:%02d" % tuple(zinfo.date_time)[:6]

At the moment I can't connect to the svn server; when I can I'll submit a
patch for the trunk and 2.5.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1698398&group_id=5470


More information about the Python-bugs-list mailing list