mirror of
https://github.com/python/cpython.git
synced 2025-10-08 08:01:55 +00:00
Issue #28449: tarfile.open() with mode "r" or "r:" now tries to open a tar
file with compression before trying to open it without compression. Otherwise it had 50% chance failed with ignore_zeros=True.
This commit is contained in:
parent
d1af5effc2
commit
a89d22aff3
3 changed files with 14 additions and 2 deletions
|
@ -1549,7 +1549,9 @@ class TarFile(object):
|
|||
|
||||
if mode in ("r", "r:*"):
|
||||
# Find out which *open() is appropriate for opening the file.
|
||||
for comptype in cls.OPEN_METH:
|
||||
def not_compressed(comptype):
|
||||
return cls.OPEN_METH[comptype] == 'taropen'
|
||||
for comptype in sorted(cls.OPEN_METH, key=not_compressed):
|
||||
func = getattr(cls, cls.OPEN_METH[comptype])
|
||||
if fileobj is not None:
|
||||
saved_pos = fileobj.tell()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue