[New-bugs-announce] [issue23991] ZipFile sanity checks
Antony Lee
report at bugs.python.org
Sat Apr 18 06:44:07 CEST 2015
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 <report at bugs.python.org>
<http://bugs.python.org/issue23991>
_______________________________________
More information about the New-bugs-announce
mailing list