[Patches] [ python-Patches-1484695 ] tarfile.py fix for #1471427 and updates

SourceForge.net noreply at sourceforge.net
Mon Jul 3 10:59:09 CEST 2006


Patches item #1484695, was opened at 2006-05-09 15:51
Message generated for change (Comment added) made by gustaebel
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=1484695&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.5
>Status: Open
Resolution: Accepted
Priority: 5
Submitted By: Lars Gustäbel (gustaebel)
Assigned to: Nobody/Anonymous (nobody)
Summary: tarfile.py fix for #1471427 and updates

Initial Comment:
I have assembled a patch that adds some features from
my own development path of tarfile.py
(http://www.gustaebel.de/lars/tarfile/) and fixes
#1471427 which made some restructuring necessary. The
patch affects Lib/tarfile.py, Lib/test/test_tarfile.py
and Doc/lib/libtarfile.tex.

The changes the patch makes are as follows:

Sets the version to 0.8.0.

Support for base256 encoding of number fields (nti()
and itn()). Up to now this was hardcoded for the
filesize field to allow filesizes greater than 8 GB but
it is applicable to all number fields.

TarInfo.tobuf() has a boolean argument "posix" which
controls how number fields are written (base256 is
non-posix).

Both unsigned and signed (Sun and NeXT) checksums are
calculated. Header validation moves from TarFile.next()
to TarInfo.frombuf(). A header is valid only if its
checksum is okay, in the past the checksum was
calculated but ignored.

The TarFile.next() method was rearranged which makes
header processing clearer and more abstract and fixes
bug #1471427. However, this change breaks the interface
for subclassing in order to implement custom member
types but makes it much easier at the same time. The
mapping TYPE_METH was removed.

A new test ReadGNULongTest was added to test_tarfile.py
and testtar.tar was updated to be able to test the GNU
extensions LONGNAME and LONGLINK.


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

>Comment By: Lars Gustäbel (gustaebel)
Date: 2006-07-03 10:59

Message:
Logged In: YES 
user_id=642936

I would like to emphasize on point (2) of my previous post,
which should be resolved before 2.5 comes out.

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

Comment By: Lars Gustäbel (gustaebel)
Date: 2006-05-18 12:00

Message:
Logged In: YES 
user_id=642936

On (1): agreed.

On (2): There is still a debug message emitted for a bad
checksum: In TarInfo.frombuf() at the bottom a ValueError is
raised if they don't match and is passed on to
TarFile.next() where it is put out as a debug message using
the _dbg() method in the except clause. The debug message
where it is now (r46040) is senseless because the try-block
will be left when TarInfo.frombuf() fails .

On (3): You're right, I attached a patch that adds another
Exception HeaderError which is raised in TarInfo.frombuf()
instead of ValueError in case of a bad header. I hope that
is acceptable.

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

Comment By: Georg Brandl (gbrandl)
Date: 2006-05-18 08:11

Message:
Logged In: YES 
user_id=849994

Jim: I agree with your comments and have committed an
improved version.

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

Comment By: Jim Jewett (jimjjewett)
Date: 2006-05-18 00:25

Message:
Logged In: YES 
user_id=764593

(1)  Why change the exception style?

When raising an instance, the style guide (PEP-8, http://
www.python.org/dev/peps/pep-0008/) prefers to construct 
that instance; the older form is left over from String 
exceptions and will be removed in Python 3.

I could understand leaving them as they were, but if you're 
going to change them to make them consistent, why not use 
the current format?

(2)  Why get rid of the debug messages (such as the 
checksum check) entirely?  Guarding them in if self.debug, 
I would understand.

(3)  I wouldn't count on str(e) (where e is any ValueError 
instance) being as meaningful as the (current version's) 
ReadError("empty, unreadable or compressed file")




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

Comment By: Georg Brandl (gbrandl)
Date: 2006-05-10 18:26

Message:
Logged In: YES 
user_id=849994

Thanks for the patch, applied as rev. 45954.

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

Comment By: Lars Gustäbel (gustaebel)
Date: 2006-05-09 15:52

Message:
Logged In: YES 
user_id=642936

Here is testtar.tar to replace Lib/test/testtar.tar.

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

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


More information about the Patches mailing list