[issue10757] zipfile.write, arcname should be bytestring

2010-12-26 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

 So, in reverse of issue 4871, it appears that in this case the API should 
 reject bytes input with an appropriate error message.

-1. It is quite common to produce ill-formed zipfiles, and other
ziptools are interpreting them in violation of the format spec.
Python needs to support creation of such broken zipfiles,
even though it may not be able to read them back.

--

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



[issue10757] zipfile.write, arcname should be bytestring

2010-12-25 Thread R. David Murray

R. David Murray rdmur...@bitdance.com added the comment:

See also msg79724 of issue 4871.  From looking at the code it appears that the 
filename must be a string, and if it contains only ASCII characters it is 
entered as ascii, while if it contains non-ascii it is encoded to utf-8 and the 
appropriate flag bits set in the archive to indicate this (I know nothing about 
the archive format, by the way, I'm just looking at the code).

So, in reverse of issue 4871, it appears that in this case the API should 
reject bytes input with an appropriate error message.

--
nosy: +r.david.murray

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



[issue10757] zipfile.write, arcname should be bytestring

2010-12-24 Thread Terry J. Reedy

Changes by Terry J. Reedy tjre...@udel.edu:


--
nosy: +aimacintyre
stage:  - unit test needed
type: compile error - behavior
versions: +Python 3.2

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



[issue10757] zipfile.write, arcname should be bytestring

2010-12-22 Thread Jacek Jabłoński

New submission from Jacek Jabłoński conexion2...@gmail.com:

file = 'somefile.dat'
filename = ółśąśółąś.dat
zip = zipfile.ZipFile('archive.zip', 'w', zipfile.ZIP_DEFLATED)
zip.write(file, filename)

above produces very nasty filename in zip archive.
*
file = 'somefile.dat'
filename = ółśąśółąś.dat
zip = zipfile.ZipFile('archive.zip', 'w', zipfile.ZIP_DEFLATED)
zip.write(file, filename.encode('cp852'))

this produces TypeError: expected an object with the buffer interface

Documentation says that:
There is no official file name encoding for ZIP files. If you have unicode file 
names, you must convert them to byte strings in your desired encoding before 
passing them to write().

I convert them to byte string but it ends with an error.
If it is documentation bug, what is the proper way to have filenames like 
ółśąśółąś in zip archive?

--
components: Library (Lib)
messages: 124499
nosy: connexion2000
priority: normal
severity: normal
status: open
title: zipfile.write, arcname should be bytestring
type: compile error
versions: Python 3.1

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



[issue10757] zipfile.write, arcname should be bytestring

2010-12-22 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

This is not a bug. Your code that produces very nasty filename is the right 
one - the file name is actually the one you asked for. The second code is also 
behaving correctly: filename already *is* a bytestring, calling .encode for it 
is meaningless.

--
nosy: +loewis
resolution:  - invalid
status: open - closed

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



[issue10757] zipfile.write, arcname should be bytestring

2010-12-22 Thread Martin v . Löwis

Martin v. Löwis mar...@v.loewis.de added the comment:

Oops, I take this back - I didn't notice you were using Python 3.1.

In any case, your first code is correct. What you get is the best you can ask 
for.

That the second case fails is indeed a bug.

--
resolution: invalid - 
status: closed - open

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