This issue tracker has been migrated to GitHub ,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2010年06月24日 18:11 by free.ekanayaka, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Messages (5) | |||
|---|---|---|---|
| msg108537 - (view) | Author: Free Ekanayaka (free.ekanayaka) | Date: 2010年06月24日 18:10 | |
The tar format allows to have memeber files whose path has a leading "./":
$ echo > foo
$ tar cf bar.tar ./foo
$ tar tf bar.tar
./foo
However the tarfile module doesn't allow this:
>>> from StringIO import StringIO
>>> from tarfile import TarInfo, TarFile
>>> info = TarInfo("./foo")
>>> fd = open("bar.tar", "w")
>>> tar = TarFile.open(fileobj=fd, mode="w")
>>> tar.addfile(info, "")
>>> tar.close()
then:
$ tar tf bar.tar
foo
So in practice the tarfile module forces the removal of leading "./"'s.
In particular this is a problem when creating .deb files (dpkg) programmatically as these contains tar files with members with a leading "./".
|
|||
| msg108540 - (view) | Author: Gustavo Niemeyer (niemeyer) * (Python committer) | Date: 2010年06月24日 18:23 | |
Please note that even if unpacking such a tar might be semantically equivalent to a version which strips out the "./" prefix, it should be possible to create a tar with valid path names such as these. In the case of debs, for instance, the files inside the tarball may contain expected path names, which means that some (badly done, perhaps) tools could *expect* the file to be exactly that which is created by the standard tools (e.g. "./debian/control"), and break down once it's not found. With this in mind, it would indeed be nice to be able to use paths prefixed with "./" in Python's tarfile. |
|||
| msg108580 - (view) | Author: Lars Gustäbel (lars.gustaebel) * (Python committer) | Date: 2010年06月25日 07:20 | |
This is a duplicate of issue6054 which has been fixed in Python 2.7 (r74571). (Hi, Gustavo!) |
|||
| msg108582 - (view) | Author: Free Ekanayaka (free.ekanayaka) | Date: 2010年06月25日 10:01 | |
Thanks for the prompt reply! Cool to know this is already fixed. |
|||
| msg108927 - (view) | Author: Gustavo Niemeyer (niemeyer) * (Python committer) | Date: 2010年06月29日 18:30 | |
Indeed, nice use of the time machine! :-) Thanks Lars! |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:02 | admin | set | github: 53317 |
| 2010年06月29日 18:30:35 | niemeyer | set | messages: + msg108927 |
| 2010年06月25日 10:01:02 | free.ekanayaka | set | messages: + msg108582 |
| 2010年06月25日 07:20:16 | lars.gustaebel | set | status: open -> closed nosy: + lars.gustaebel messages: + msg108580 assignee: lars.gustaebel resolution: duplicate |
| 2010年06月24日 18:23:29 | niemeyer | set | nosy:
+ niemeyer messages: + msg108540 |
| 2010年06月24日 18:11:00 | free.ekanayaka | create | |