Toshio Kuratomi added the comment:

Okay, here's the first version of a patch to add surrogate support to a 
zipfile.  I think it's the minimum required to fix this bug.

When archiving, if a filename contains surrogateescape'd bytes, it switches to 
cp437 when it saves the filename into the zipfile.  This seems to be the 
strategy of other zip tools.  Nothing changes when unarchiving (probably to 
deal with what comes out of other tools).

The documentation is also updated to mention that unknown encodings are a 
problem that the zipfile module doesn't handle automatically for you.

I think we could do better but this is a major improvement over the status quo 
(no tracebacks).  Would someone care to review this for merge and then we could 
work on adding some notion of a user-specified encoding to override cp437 
encoding on dearchiving.  (which I think would satisfy:  issue10614, 
issue10972).

The use case in issue10757 might be fixed by this patch (or this patch plus the 
user specified encoding).  Have to look a little harder at it.

----------
keywords: +patch
Added file: http://bugs.python.org/file29517/python3-zipfile-surrogate.patch

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue16310>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to