[issue26283] zipfile can not handle the path build by os.path.join()

Ezio Melotti report at bugs.python.org
Fri Mar 18 14:59:15 EDT 2016


Ezio Melotti added the comment:

I don't think this is a bug.  The ZIP format specification requires the use of forward slashes[0]:

   4.4.17 file name: (Variable)

       4.4.17.1 The name of the file, with optional relative path.
       The path stored MUST not contain a drive or
       device letter, or a leading slash.  All slashes
       MUST be forward slashes '/' as opposed to
       backwards slashes '\' for compatibility with Amiga
       and UNIX file systems etc.

os.path.join() will use different path separators depending on the system.  If you don't want to hardcode the slashes in a string literal, you can simply use '/'.join(...) instead of os.path.join().

[0]: https://pkware.cachefly.net/webdocs/casestudies/APPNOTE.TXT

----------
nosy: +ezio.melotti
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

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


More information about the Python-bugs-list mailing list