[docs] [issue22046] ZipFile.read() should mention that it might throw NotImplementedError
Ezio Melotti
report at bugs.python.org
Wed Aug 6 05:11:46 CEST 2014
Ezio Melotti added the comment:
After further investigation it seems to me that read can't raise NotImplementedError. ZipFile also won't raise it, but will raise a RuntimeError:
>>> zipfile.ZipFile('spam.zip', 'w', compression=zipfile.ZIP_BZIP2)
RuntimeError: Compression requires the (missing) bz2 module
By looking at the code, ZipFile calls _check_compression (Lib/zipfile.py:904) and _check_compression raises RuntimeError (Lib/zipfile.py:579).
ZipExtFile calls _get_decompressor (Lib/zipfile.py:651) and _get_decompressor raises NotImplemented (Lib/zipfile.py:610).
This behavior seems inconsistent and perhaps should be fixed (in this case a new issue should be created), however this will probably be backward-incompatible.
Regardless of this, it seems that currently NotImplementedError can be raised in some situations, and the zipfile docs don't mention it, so the doc can still be improved.
@Martin
Do you have any opinion on the aforementioned inconsistency?
@Jason
Did you actually manage to get a NotImplementedError from ZipFile.read() or from somewhere else?
----------
assignee: docs at python -> ezio.melotti
nosy: +ezio.melotti, loewis, serhiy.storchaka
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22046>
_______________________________________
More information about the docs
mailing list