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.

classification
Title: tarfile local name is local, should be abspath
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: lars.gustaebel Nosy List: blais, georg.brandl, lars.gustaebel, loewis
Priority: normal Keywords:

Created on 2005-08-12 02:26 by blais, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
tarfile-bug.py blais, 2005-08-15 17:33 Script to reproduce the tarfile bug mentioned above.
Messages (7)
msg26026 - (view) Author: Martin Blais (blais) * (Python committer) Date: 2005-08-12 02:26
I ran into a bug using the tarfile module with
compression from a directory that did not exist
anymore, and this exhibits a bug in the tarfile module.
 I'm not completely sure how to fix it with certainty,
so instead of filing a quick patch, I submit a bug so
people familiar with the module can have a look first.

The problem is that when you open a tarfile with gz or
bz2 compression, the TarFile object is opened with a
filename that is not absolute, just local (basename is
called) but the actual file is using a file-like object.  

Now, when you add a new entry, there is a check in the
TarFile.add method that checks if we're not adding the
archive itself into the tarfile, and this method calls
abspath.  Calling abspath on the name that has been
basename'd is incorrect and a bug.  It happens not to
fail nor cause any problems when called from an
existing directory (the test returns false), but it
does not do the job it is supposed to.  When the CWD
has been deleted, calling abspath fails with an
OSError, which brings out the problem.

Some code to reproduce the bug is provided in an
attachment.
msg26027 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2005-08-15 11:39
Logged In: YES 
user_id=642936

Could you please attach the test code you mentioned?
msg26028 - (view) Author: Martin Blais (blais) * (Python committer) Date: 2005-08-15 17:34
Logged In: YES 
user_id=10996

Oops, that was silly.  My apologies.   Here goes the file...
msg26029 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2005-08-17 12:34
Logged In: YES 
user_id=642936

Thank you very much for your report. I added patch #1262036
that ought to fix the problem.
msg26030 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-08-24 06:08
Logged In: YES 
user_id=21627

This was fixed with said patch.
msg26031 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2005-08-25 09:04
Logged In: YES 
user_id=1188172

The patch has been reversed, so reopening.
msg26032 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2006-12-23 18:17
Fixed. See patch #1262036.
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42269
2005-08-12 02:26:29blaiscreate