New submission from Antony Lee: 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. ---------- components: Library (Lib) messages: 241396 nosy: Antony.Lee priority: normal severity: normal status: open title: ZipFile sanity checks versions: Python 3.4, Python 3.5 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue23991> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com