[docs] [issue11160] ZipFile.comment expects bytes
report at bugs.python.org
Thu Oct 25 18:17:30 CEST 2012
Serhiy Storchaka added the comment:
The ZIP specification says:
If general purpose bit 11 is unset, the file name and comment should conform
to the original ZIP character encoding. If general purpose bit 11 is set, the
filename and comment must support The Unicode Standard, Version 4.1.0 or
greater using the character encoding form defined by the UTF-8 storage
specification. The Unicode Standard is published by the The Unicode
Consortium (www.unicode.org). UTF-8 encoded data stored within ZIP files
is expected to not include a byte order mark (BOM).
Also there is extension for UTF-8 encoded file comment. All this means the file comment should be interpreted as an unicode string.
However the specification says nothing about .ZIP file comment (except that encryption or data authentication is applied to it).
Since changeset 4186f20d9fa4 ZipFile.comment raises TypeError on try to assign non-bytes. I think the documentation should be clarified.
components: -Library (Lib)
stage: -> needs patch
type: -> enhancement
versions: +Python 3.3, Python 3.4
Python tracker <report at bugs.python.org>
More information about the docs