[issue6839] zipfile can't extract file

Jim Jewett report at bugs.python.org
Fri May 2 16:55:38 CEST 2014


Jim Jewett added the comment:

On Fri, May 2, 2014 at 1:14 AM, Adam Polkosnik
> The problems documented here are related to two cases (both apparently arriving from world of windows):

Good!  I had thought you had even more!

> 1. two relative paths with inverted slash in one of them (test\test2.txt vs test/test2.txt)

My understanding from earlier -- and I may have been reading too much
into some of the comments -- is that the standard defined \filename as
an inferior alias for /filename and supported the fix.

Notably, if you're extracting on windows with windows conventions,
then windows will treat them identically anyhow.

If you're extracting a windows file to a unix environment, then \t
really should be translated to /t.

> 2. relative path vs absolute path (windows\temp\test.txt vs c:\windows\temp\test.txt)

These really are different, as leaving off the "C:" should mean
"current drive", which will often (but not always) be C:

This (and differing capitalization) are among the reasons to do the
filename fix in a separate method, so that subclasses with more local
knowledge can more easily do the right thing.

Note that for python 3.4 and newer, pathlib <URL:
https://docs.python.org/3/library/pathlib.html> may be helpful.  It
would probably even be possible to backport the essential parts as an
implementation detail. But I'm not sure if that could be done
compatibly with maintenance releases, or how much work it would take.

> The extraction part seems to be doing a good job at writing the files into sane locations.
> IMHO, there's no point in trying to replace slashes or otherwise "normalize", as this would fix the cases where the presence of an inverted slashes should be noted in debug output.

My understanding had been that it was failing to extract entirely.  So
exactly what is the problem?

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6839>
_______________________________________


More information about the Python-bugs-list mailing list