[ python-Bugs-1488634 ] tarfile.TarFile.open can might incorrectly raise ValueError

SourceForge.net noreply at sourceforge.net
Mon May 15 21:31:47 CEST 2006


Bugs item #1488634, was opened at 2006-05-15 06:25
Message generated for change (Comment added) made by gbrandl
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1488634&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: Python Library
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Andrew Bennetts (spiv)
Assigned to: Nobody/Anonymous (nobody)
Summary: tarfile.TarFile.open can might incorrectly raise ValueError

Initial Comment:
tarfile.TarFile.open, if passed a fileobj argument for
a valid plain tar or tar.gz file, might fail to open
the file, and instead unexpectedly raise "ValueError:
no support for external file objects".

"open" iterates over TarFile.OPEN_METH, which is a
dictionary, to try find a method that works for a given
file.  If the internal, undefined, ordering of that
dict returns the "bz2" key before the right one for a
given file, and the fileobj argument is passed, TarFile
will attempt to call bz2open with the fileobj method,
which then raises "ValueError: no support for external
file objects", which then is not caught.

The end result is that it's possible to pass a valid
tar or tar.gz file to TarFile.open in the fileobj
argument, but get a ValueError from bz2open instead of
a TarFile object.


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

>Comment By: Georg Brandl (gbrandl)
Date: 2006-05-15 19:31

Message:
Logged In: YES 
user_id=849994

Fixed with commit of said patch.

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

Comment By: Lars Gustäbel (gustaebel)
Date: 2006-05-15 14:19

Message:
Logged In: YES 
user_id=642936

I just submitted patch #1488881 that would solve your
problem as a side-effect. Thanks for your report.

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

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


More information about the Python-bugs-list mailing list