[issue11160] ZipFile.comment expects bytes

2022-03-19 Thread Irit Katriel


Irit Katriel  added the comment:

The documentation has been updated by now [1]:

ZipFile.comment
The comment associated with the ZIP file as a bytes object. If assigning a 
comment to a ZipFile instance created with mode 'w', 'x' or 'a', it should be 
no longer than 65535 bytes. Comments longer than this will be truncated.


[1] https://docs.python.org/3/library/zipfile.html#zipfile.ZipFile.comment

--
nosy: +iritkatriel
resolution:  -> out of date
stage: needs patch -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11160] ZipFile.comment expects bytes

2012-10-25 Thread Serhiy Storchaka

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)
nosy: +serhiy.storchaka
stage:  - needs patch
type:  - enhancement
versions: +Python 3.3, Python 3.4

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11160
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11160] ZipFile.comment expects bytes

2011-02-13 Thread STINNER Victor

STINNER Victor victor.stin...@haypocalc.com added the comment:

 can we use str.encode() function to convert string into bytes ?

Can you try different ZIP archivers to check which encoding is expected? 
WinZip, WinRAR, 7-zip, zip command line program on Linux, etc.

And do you have any reference into a ZIP documentation?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11160
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11160] ZipFile.comment expects bytes

2011-02-12 Thread yeswanth

yeswanth swamiyeswa...@yahoo.com added the comment:

IMO the Zipfile.comment should accept strings too instead of just accepting 
bytes , so patching should help i guess

--
nosy: +swamiyeswanth

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11160
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11160] ZipFile.comment expects bytes

2011-02-12 Thread yeswanth

yeswanth swamiyeswa...@yahoo.com added the comment:

can we use str.encode() function to convert string into bytes ?

--

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11160
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue11160] ZipFile.comment expects bytes

2011-02-09 Thread Xuanji Li

New submission from Xuanji Li xua...@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@python
components: Documentation, Library (Lib)
messages: 128217
nosy: docs@python, haypo, xuanji
priority: normal
severity: normal
status: open
title: ZipFile.comment expects bytes
versions: Python 3.2

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue11160
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com