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 iteration can break (on Windows) if file has links
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: glchapman, lars.gustaebel, loewis
Priority: normal Keywords:

Created on 2005-01-11 20:54 by glchapman, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg23932 - (view) Author: Greg Chapman (glchapman) Date: 2005-01-11 20:54
I ran into this with a simple loop trying to detar
Pyrex-0.9.3:

for info in tarfile:
    tarfile.extract(info)

I called the above immediately after calling
tarfile.open, so the returned iterator was an instance
of TarIter.  The problem is that Pyrex includes some
symbolic links.  When TarFile.makelink finds that
os.symlink is missing (on Windows) it then does
getmember to find the info for the referenced file. 
The getmember method results in a call to getmembers,
which loads all the infos into the members list. 
However, this breaks the TarIter, since it assumes the
members have not yet been loaded.

Not sure what the best fix for this is; in my script, I
switched over to using getmembers rather than the iterator.
msg23933 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2005-01-16 17:40
Logged In: YES 
user_id=642936

I wrote a patch (#1103407) that should fix this.
Thank you for pointing that out.
msg23934 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2005-03-03 23:16
Logged In: YES 
user_id=21627

Fixed with said patch.
History
Date User Action Args
2022-04-11 14:56:09adminsetgithub: 41427
2005-01-11 20:54:29glchapmancreate