[issue9071] TarFile doesn't support member files with a leading "./"

Free Ekanayaka report at bugs.python.org
Thu Jun 24 20:11:02 CEST 2010


New submission from Free Ekanayaka <free at 64studio.com>:

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 "./".

----------
components: Library (Lib)
messages: 108537
nosy: free.ekanayaka
priority: normal
severity: normal
status: open
title: TarFile doesn't support member files with a leading "./"
type: behavior

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


More information about the Python-bugs-list mailing list