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.TarFile.open can might incorrectly raise ValueError
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, lars.gustaebel, spiv
Priority: normal Keywords:

Created on 2006-05-15 06:25 by spiv, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (3)
msg28524 - (view) Author: Andrew Bennetts (spiv) Date: 2006-05-15 06:25
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.
msg28525 - (view) Author: Lars Gustäbel (lars.gustaebel) * (Python committer) Date: 2006-05-15 14:19
Logged In: YES 
user_id=642936

I just submitted patch #1488881 that would solve your
problem as a side-effect. Thanks for your report.
msg28526 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2006-05-15 19:31
Logged In: YES 
user_id=849994

Fixed with commit of said patch.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43356
2006-05-15 06:25:21spivcreate