[Tutor] Anyone using tarfile?

Kent Johnson kent37 at tds.net
Tue Jul 15 13:01:03 CEST 2008


On Tue, Jul 15, 2008 at 3:21 AM, Terry Carroll <carroll at tjc.com> wrote:

> C:\test\freedb>playtar.py
> Traceback (most recent call last):
>  File "C:\test\freedb\playtar.py", line 10, in <module>
>    RC = tf.extract(sample)
>  File "C:\Python25\lib\tarfile.py", line 1495, in extract
>    self._extract_member(tarinfo, os.path.join(path, tarinfo.name))
>  File "C:\Python25\lib\tarfile.py", line 1562, in _extract_member
>    if upperdirs and not os.path.exists(upperdirs):
>  File "C:\Python25\lib\ntpath.py", line 255, in exists
>    st = os.stat(path)
> TypeError: stat() argument 1 must be (encoded string without NULL bytes),
> not str

The problem seems to be in the file path. Have you successfully
untarred the file using a different tool? Have you tried downloading
the file again?

What version of Python are you using? I have 2.5.2 and the line
numbers in my tarfile.py are quite different than yours. The changelog
for Python 2.5.2 shows many fixes to tarfile so an upgrade may be in
order.
http://www.python.org/download/releases/2.5.2/NEWS.txt

> During some earlier poking around, I see some interesting things: instead
> of sample.name being "data/c410951c" (13 characters) or "/data/c410951c"
> (14 characters) as I would expect, it's a 169-character string: "
> 11034624707 11032232071 /data/c410951c".  I think those are zeroes, not
> blanks.
>
> Curiously, there is also another attribute named "prefix" that is not
> documented in the tarfile.py documentation.  "prefix" is a 155-character
> string that is equal to the first 155 characters of this oddly-too-long
> name.  In fact, if you cut off this "prefix" from the name, you're left
> with "/data/c410951c", whic his kind of what I was expecting name to be in
> the first place.

My version of the source picks up a prefix string and adds it to the
start of the path unless the file is a "GNU sparse" file.

Kent


More information about the Tutor mailing list