[Patches] [ python-Patches-1583880 ] tarfile.py: better use of TarInfo objects with longnames

SourceForge.net noreply at sourceforge.net
Tue Oct 24 18:38:22 CEST 2006


Patches item #1583880, was opened at 2006-10-24 18:38
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1583880&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Library (Lib)
Group: Python 2.6
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Lars Gustäbel (gustaebel)
Assigned to: Nobody/Anonymous (nobody)
Summary: tarfile.py: better use of TarInfo objects with longnames

Initial Comment:
When a TarInfo object with a long name is added to a
TarFile, the .name attribute is garbled during the
special processing involved with long names. This is
true for both posix and gnu mode and has historical
"design" reasons.

In posix mode, a long name is split in two. TarInfo's
prefix attr gets the first part, the name attr the
second one.
In gnu mode, a long name is truncated up to LENGTH_NAME
(100) chars and stored the TarInfo's name attr.

So, if you open a TarFile for writing, add a few files
with long names to it and call the getnames() method
for that still open file, the names returned are all
cut. The getmember() method will not work, because all
names have changed.

On top of that, if a user adds a TarInfo object to a
TarFile it is not copied. So, it is undefined what
happens if the user uses the same TarInfo object
several times with changed attributes. The problem
described in bug #1583537 (now deleted) was partly
caused by this.

The attached patch makes it possible to use the same
TarInfo object several times by copying it in
TarFile.addfile(), removes the (undocumented)
TarInfo.prefix attr and leaves TarInfo.name alone.

I think this should be backported to 2.5 as well.


----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1583880&group_id=5470


More information about the Patches mailing list