[issue31557] tarfile: incorrectly treats regular file as directory

Joe Tsai report at bugs.python.org
Tue Oct 3 18:07:23 EDT 2017


Joe Tsai <joetsai at google.com> added the comment:

This bug is not platform specific.

I've attached a reproduction:
$ python
>>> import tarfile
>>> tarfile.open("test.tar", "r").next().isdir()
True

$ tar -tvf test.tar
-rw-rw-r-- 0/0               0 1969-12-31 16:00 123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/123456789/foo.txt
$ tar --version
tar (GNU tar) 1.27.1

For some background, this bug was original filed against the Go standard library (for which I am the maintainer of the Go implementation of tar). When I investigated the issue, I discovered that Go was doing the right thing, and that the discrepancy was due to the check I pointed to earlier. The GNU tool indicates that this is a regular file as well.

----------
Added file: https://bugs.python.org/file47188/test.tar

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue31557>
_______________________________________


More information about the Python-bugs-list mailing list