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

SourceForge.net noreply at sourceforge.net
Mon May 15 08:25:22 CEST 2006


Bugs item #1488634, was opened at 2006-05-15 16:25
Message generated for change (Tracker Item Submitted) made by Item Submitter
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: Open
Resolution: None
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.


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

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