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.

Author cbrannon
Recipients cbrannon, swarren
Date 2008-07-17.22:46:59
SpamBayes Score 0.0032350945
Marked as misclassified No
Message-id <1216334821.01.0.29303854521.issue3394@psf.upfronthosting.co.za>
In-reply-to
Content
What value should the new archive entry's external_attr attribute have?
ZipFile.write sets it to the permissions of the file being archived, but
writestr is archiving a string, not a file.  Setting it to 0600 &lt;&lt; 16
seems reasonable.

Stephen's script exposed a second bug in writestr.  When passed a name
rather than a ZipInfo instance, the new archive member receives a timestamp
of 01/01/1980.  However, the docs say that the timestamp should correspond to
the current date and time.
ZipFile.writestr begins with the following code:

    def writestr(self, zinfo_or_arcname, bytes):
        """Write a file into the archive.  The contents is the string
        'bytes'.  'zinfo_or_arcname' is either a ZipInfo instance or
        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())[:6])
            zinfo.compress_type = self.compression

The "date_time=" line should read:

                            zinfo.date_time=time.localtime(time.time())[:6])
History
Date User Action Args
2008-07-17 22:47:01cbrannonsetspambayes_score: 0.00323509 -> 0.0032350945
recipients: + cbrannon, swarren
2008-07-17 22:47:01cbrannonsetspambayes_score: 0.00323509 -> 0.00323509
messageid: <1216334821.01.0.29303854521.issue3394@psf.upfronthosting.co.za>
2008-07-17 22:47:00cbrannonlinkissue3394 messages
2008-07-17 22:46:59cbrannoncreate