[issue10757] zipfile.write, arcname should be bytestring

Jacek Jabłoński report at bugs.python.org
Wed Dec 22 13:44:06 CET 2010


New submission from Jacek Jabłoński <conexion2000 at 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 <report at bugs.python.org>
<http://bugs.python.org/issue10757>
_______________________________________


More information about the Python-bugs-list mailing list