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.py longnames are truncated in getnames()
Type: Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: lars.gustaebel, loewis
Priority: normal Keywords: patch

Created on 2004-09-16 08:44 by lars.gustaebel, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
membernames.patch lars.gustaebel, 2004-09-16 08:44 patch against Lib/tarfile.py
Messages (2)
msg46908 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2004-09-16 08:44
When a TarFile object reads a tar archive, it scans
through the headers, converts them into TarInfo objects
and adds them to the internal data structures:

self.members.append(tarinfo)
self.membernames.append(tarinfo.name)

When a GNU longname member is processed, it is added at
a point in time when its name attribute has not yet
been replaced with the longname, so longnames in
self.membernames are truncated and therefore unusable.

This problem could have been fixed with a quick/dirty
hack. But I decided to remove self.membernames
completely because it is redundant. getnames() which
was the public interface to it now generates a list
on-the-fly from the list of members, so it always
reflects the actual state.

I encountered another small bug on the way. The docs
for TarFile.getmember() state: "If a member occurs more
than once in the archive, its last occurence is assumed
to be the most up-to-date version."
It was never implemented like that, so I fixed it, too.
msg46909 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2004-09-18 09:09
Logged In: YES 
user_id=21627

Thanks for the patch. Applied as

tarfile.py 1.20
NEWS 1.1137
History
Date User Action Args
2022-04-11 14:56:07adminsetgithub: 40919
2004-09-16 08:44:18lars.gustaebelcreate