[New-bugs-announce] [issue11160] ZipFile.comment expects bytes

Xuanji Li report at bugs.python.org
Wed Feb 9 16:09:00 CET 2011

New submission from Xuanji Li <xuanji at gmail.com>:

The documentation for zipfile describes ZipFile.comment as "The comment text associated with the ZIP file." From reading this I expect that setting it to a string is ok; however ZipFile.comment must actually be set to bytes (or a bytes-like object, I am not very sure).

This may also unexpectedly affect old code because I saw one patch on the bug tracker that was written just last year that set ZipFile.comment to a string. 

IMO there are 2 ways to fix:

1) Change docs to mention that ZipFile.comment only accepts bytes
2) Patch zipfile.py to accept string and try to convert, throwing an error if the conversion fails

assignee: docs at python
components: Documentation, Library (Lib)
messages: 128217
nosy: docs at python, haypo, xuanji
priority: normal
severity: normal
status: open
title: ZipFile.comment expects bytes
versions: Python 3.2

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list