[issue10614] ZipFile: add a filename_encoding argument

2016-12-26 Thread INADA Naoki

INADA Naoki added the comment:

Thanks. Patch posted in issue28080 looks better than mine.

--
stage: patch review -> 
superseder:  -> Allow reading member names with bogus encodings in zipfile

___
Python tracker 

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



[issue10614] ZipFile: add a filename_encoding argument

2016-12-26 Thread INADA Naoki

Changes by INADA Naoki :


Added file: http://bugs.python.org/file46043/10614-zipfile-encoding.patch

___
Python tracker 

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



[issue10614] ZipFile: add a filename_encoding argument

2016-12-26 Thread Serhiy Storchaka

Serhiy Storchaka added the comment:

See also issue28080.

--

___
Python tracker 

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



[issue10614] ZipFile: add a filename_encoding argument

2016-12-26 Thread INADA Naoki

Changes by INADA Naoki :


Removed file: http://bugs.python.org/file46042/10614-zipfile-encoding.patch

___
Python tracker 

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



[issue10614] ZipFile: add a filename_encoding argument

2016-12-26 Thread INADA Naoki

Changes by INADA Naoki :


--
components: +Library (Lib) -Extension Modules
stage:  -> patch review
versions: +Python 3.6, Python 3.7 -Python 3.2, Python 3.3
Added file: http://bugs.python.org/file46042/10614-zipfile-encoding.patch

___
Python tracker 

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



[issue10614] ZipFile: add a filename_encoding argument

2015-09-11 Thread irdb

Changes by irdb :


--
nosy: +irdb

___
Python tracker 

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



[issue10614] ZipFile: add a filename_encoding argument

2015-07-21 Thread Ethan Furman

Changes by Ethan Furman et...@stoneleaf.us:


--
nosy:  -ethan.furman

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



[issue10614] ZipFile: add a filename_encoding argument

2014-04-20 Thread INADA Naoki

Changes by INADA Naoki songofaca...@gmail.com:


--
nosy: +naoki

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



[issue10614] ZipFile: add a filename_encoding argument

2014-01-21 Thread Laurent Mazuel

Changes by Laurent Mazuel laurent.maz...@gmail.com:


--
nosy: +Laurent.Mazuel

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



[issue10614] ZipFile: add a filename_encoding argument

2013-10-18 Thread Sergey Dorofeev

Sergey Dorofeev added the comment:

I'd like to submit patch to support zip archives created on systems that use 
non-US codepage (e.g. russian CP866).
Codepage would be specified in additional parameter of ZipFile constructor, 
named codepage.
If it is not specified, old behavior is preserved (use CP437).

--- zipfile.py-orig 2013-09-18 16:45:56.0 +0400
+++ zipfile.py  2013-10-15 00:24:06.105157572 +0400
@@ -885,7 +885,7 @@
 fp = None   # Set here since __del__ checks it
 _windows_illegal_name_trans_table = None

-def __init__(self, file, mode=r, compression=ZIP_STORED, 
allowZip64=False):
+def __init__(self, file, mode=r, compression=ZIP_STORED, 
allowZip64=False, codepage='cp437'):
 Open the ZIP file with mode read r, write w or append a.
 if mode not in (r, w, a):
 raise RuntimeError('ZipFile() requires mode r, w, or a')
@@ -901,6 +901,7 @@
 self.mode = key = mode.replace('b', '')[0]
 self.pwd = None
 self._comment = b''
+self.codepage = codepage

 # Check if we were passed a file-like object
 if isinstance(file, str):
@@ -1002,7 +1003,7 @@
 filename = filename.decode('utf-8')
 else:
 # Historical ZIP filename encoding
-filename = filename.decode('cp437')
+filename = filename.decode(self.codepage)
 # Create ZipInfo instance to store file information
 x = ZipInfo(filename)
 x.extra = fp.read(centdir[_CD_EXTRA_FIELD_LENGTH])
@@ -1157,7 +1158,7 @@
 # UTF-8 filename
 fname_str = fname.decode(utf-8)
 else:
-fname_str = fname.decode(cp437)
+fname_str = fname.decode(self.codepage)

 if fname_str != zinfo.orig_filename:
 raise BadZipFile(

--
nosy: +Sergey.Dorofeev

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



[issue10614] ZipFile: add a filename_encoding argument

2013-10-18 Thread STINNER Victor

STINNER Victor added the comment:

Please rename codepage to encoding. By the way, 437 is a codepage, cp437 is
a (python) encoding.

I don't think that ZIP is limited to windows. I uncompressed zip files many
times on various OSes, github also produces zip (and github is probably not
using windows). And codepage term is only used on windows. Mac OS 9 users
might produce mac roman filenames.

--

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



[issue10614] ZipFile: add a filename_encoding argument

2013-10-18 Thread Sergey Dorofeev

Sergey Dorofeev added the comment:

OK, here you are:

--- zipfile.py-orig 2013-09-18 16:45:56.0 +0400
+++ zipfile.py  2013-10-19 01:59:07.444346674 +0400
@@ -885,7 +885,7 @@
 fp = None   # Set here since __del__ checks it
 _windows_illegal_name_trans_table = None

-def __init__(self, file, mode=r, compression=ZIP_STORED,
allowZip64=False):
+def __init__(self, file, mode=r, compression=ZIP_STORED,
allowZip64=False, encoding='cp437'):
 Open the ZIP file with mode read r, write w or append
a.
 if mode not in (r, w, a):
 raise RuntimeError('ZipFile() requires mode r, w, or a')
@@ -901,6 +901,7 @@
 self.mode = key = mode.replace('b', '')[0]
 self.pwd = None
 self._comment = b''
+self.encoding = encoding

 # Check if we were passed a file-like object
 if isinstance(file, str):
@@ -1001,8 +1002,8 @@
 # UTF-8 file names extension
 filename = filename.decode('utf-8')
 else:
-# Historical ZIP filename encoding
-filename = filename.decode('cp437')
+# Historical ZIP filename encoding, default is CP437
+filename = filename.decode(self.encoding)
 # Create ZipInfo instance to store file information
 x = ZipInfo(filename)
 x.extra = fp.read(centdir[_CD_EXTRA_FIELD_LENGTH])
@@ -1157,7 +1158,7 @@
 # UTF-8 filename
 fname_str = fname.decode(utf-8)
 else:
-fname_str = fname.decode(cp437)
+fname_str = fname.decode(self.encoding)

 if fname_str != zinfo.orig_filename:
 raise BadZipFile(

On Fri, Oct 18, 2013 at 11:47 AM, STINNER Victor rep...@bugs.python.orgwrote:


 STINNER Victor added the comment:

 Please rename codepage to encoding. By the way, 437 is a codepage, cp437 is
 a (python) encoding.

 I don't think that ZIP is limited to windows. I uncompressed zip files many
 times on various OSes, github also produces zip (and github is probably not
 using windows). And codepage term is only used on windows. Mac OS 9 users
 might produce mac roman filenames.

 --

 ___
 Python tracker rep...@bugs.python.org
 http://bugs.python.org/issue10614
 ___


--

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



[issue10614] ZipFile: add a filename_encoding argument

2013-10-14 Thread Ethan Furman

Changes by Ethan Furman et...@stoneleaf.us:


--
nosy: +ethan.furman

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



[issue10614] ZipFile: add a filename_encoding argument

2012-07-13 Thread Martin v . Löwis

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

umedoblock: your patch is incorrect, as it produces moji-bake. if there is a 
file name b'f\x94n', it will decode as sjis under your patch (to u'f\u99ac'), 
even though it was meant as cp437 (i.e. u'f\xf6n').

--

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



[issue10614] ZipFile: add a filename_encoding argument

2012-07-13 Thread umedoblock

umedoblock umedobl...@gmail.com added the comment:

Hi, Martin.
I tried your test case with attached file.
And I got below result.

p3 ./encodings.py
encoding: sjis, filename: f馬
encoding: cp437, filename: fön
sjis_filename = f馬
cp437_filename = fön

There are two success cases.
So I think that the patch needs to change default_encoding
before or in _decode_filename().

But I have no idea about how to change a default_encoding.

--
Added file: http://bugs.python.org/file26376/encodings.py

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



[issue10614] ZipFile: add a filename_encoding argument

2012-07-12 Thread umedoblock

umedoblock umedobl...@gmail.com added the comment:

I fixed this problem.
I make new methos _decode_filename().

--
keywords: +patch
nosy: +umedoblock
Added file: http://bugs.python.org/file26372/zipfile.patch

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



[issue10614] ZipFile: add a filename_encoding argument

2012-04-07 Thread Serhiy Storchaka

Changes by Serhiy Storchaka storch...@gmail.com:


--
nosy: +storchaka

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



[issue10614] ZipFile: add a filename_encoding argument

2011-05-18 Thread STINNER Victor

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

I closed issue #12048 as a duplicate of this issue: yaoyu wants to uncompress a 
ZIP file having filenames encoded to GBK.

--

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



[issue10614] ZipFile: add a filename_encoding argument

2011-01-31 Thread STINNER Victor

Changes by STINNER Victor victor.stin...@haypocalc.com:


--
title: ZipFile and CP932 encoding - ZipFile: add a filename_encoding argument

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