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 Antony.Lee
Recipients Antony.Lee
Date 2015-04-18.04:44:06
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429332247.71.0.71910598875.issue23991@psf.upfronthosting.co.za>
In-reply-to
Content
ZipFile.{open,read} could raise IsADirectoryError when called on a directory entry, rather than return an empty bytes.
ZipFile.writestr could fail writing non-empty bytes to a directory entry.

Use case for open and read: I was trying to write a zip merger (taking multiple zip files and merge them into a single zip).  Unfortunately, the obvious approach (iterate on the original infolists, extract each of them and writestr them to the new ZipFile object) created invalid zip files because it'll create empty files for each directory.  Raising IsADirectoryError would have brought attention to the issue much earlier.

The suggested modification to writestr is a bit different, but also makes sense because the bytes argument is not written anywhere anyways in the case of directory entries.
History
Date User Action Args
2015-04-18 04:44:07Antony.Leesetrecipients: + Antony.Lee
2015-04-18 04:44:07Antony.Leesetmessageid: <1429332247.71.0.71910598875.issue23991@psf.upfronthosting.co.za>
2015-04-18 04:44:07Antony.Leelinkissue23991 messages
2015-04-18 04:44:06Antony.Leecreate