diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-30 18:56:23 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-10-30 18:56:23 (GMT) |
commit | 2f4453eff8296e6b5e57c237d47288d9a9842b00 (patch) | |
tree | 01394f25acffe7bc0a46055a5cd6fa65811c71df /Lib/tarfile.py | |
parent | 7984bff52a9952219a3c15b88ff6514244dd7498 (diff) | |
parent | a89d22aff3fb1e67f8f08eac22b08a58dfa048a8 (diff) | |
download | cpython-2f4453eff8296e6b5e57c237d47288d9a9842b00.zip cpython-2f4453eff8296e6b5e57c237d47288d9a9842b00.tar.gz cpython-2f4453eff8296e6b5e57c237d47288d9a9842b00.tar.bz2 |
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.
Diffstat (limited to 'Lib/tarfile.py')
-rwxr-xr-x | Lib/tarfile.py | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index a62ab82..b78b1b1 100755 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1554,7 +1554,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() |