]> granicus.if.org Git - python/commitdiff
Fix 1698398: Zipfile.printdir() crashed because the format string expected a tuple...
authorRaymond Hettinger <python@rcn.com>
Mon, 14 Jan 2008 22:58:05 +0000 (22:58 +0000)
committerRaymond Hettinger <python@rcn.com>
Mon, 14 Jan 2008 22:58:05 +0000 (22:58 +0000)
Lib/zipfile.py
Misc/NEWS

index ab9c93fed5c909539f00dd64cec7e8f834459daf..471cffc986edb8c1e75f4944983a270f3973d104 100644 (file)
@@ -710,7 +710,7 @@ class ZipFile:
         """Print a table of contents for the zip file."""
         print "%-46s %19s %12s" % ("File Name", "Modified    ", "Size")
         for zinfo in self.filelist:
-            date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time
+            date = "%d-%02d-%02d %02d:%02d:%02d" % zinfo.date_time[:6]
             print "%-46s %s %12d" % (zinfo.filename, date, zinfo.file_size)
 
     def testzip(self):
@@ -961,7 +961,7 @@ class ZipFile:
         the name of the file in the archive."""
         if not isinstance(zinfo_or_arcname, ZipInfo):
             zinfo = ZipInfo(filename=zinfo_or_arcname,
-                            date_time=time.localtime(time.time()))
+                            date_time=time.localtime(time.time())[:6])
             zinfo.compress_type = self.compression
         else:
             zinfo = zinfo_or_arcname
index 0ef721fc8be22b8ddeb167c8893f85095557beb8..32dab1059cdd6c40e0e23fc9c2151d0d2d9b98c7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -363,6 +363,9 @@ Core and builtins
 Library
 -------
 
+- Issue #1698398 Zipfile.printdir() crashed because the format string
+  expected a tuple type of length six instead of time.struct_time object.
+
 - Issue #1780: The Decimal constructor now accepts arbitrary leading
   and trailing whitespace when constructing from a string.
   Context.create_decimal no longer accepts trailing newlines.