diff options
Diffstat (limited to 'Lib/tarfile.py')
-rw-r--r-- | Lib/tarfile.py | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 658f2144bf..178514470e 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1141,9 +1141,13 @@ class TarFile(object): # Find out which *open() is appropriate for opening the file. for comptype in cls.OPEN_METH: func = getattr(cls, cls.OPEN_METH[comptype]) + if fileobj is not None: + saved_pos = fileobj.tell() try: return func(name, "r", fileobj) except (ReadError, CompressionError): + if fileobj is not None: + fileobj.seek(saved_pos) continue raise ReadError("file could not be opened successfully") |