diff options
| author | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-23 18:36:46 (GMT) | 
|---|---|---|
| committer | Antoine Pitrou <solipsis@pitrou.net> | 2010-09-23 18:36:46 (GMT) | 
| commit | 95f5560b46b24a42468dda2f2ebcc3eba271c28d (patch) | |
| tree | 3a945aa450620ae616ffde7c619cde07e58c69e2 /Lib/tarfile.py | |
| parent | e5768cf348ec353dff7e3f2144f4e1690a094a64 (diff) | |
| download | cpython-95f5560b46b24a42468dda2f2ebcc3eba271c28d.zip cpython-95f5560b46b24a42468dda2f2ebcc3eba271c28d.tar.gz cpython-95f5560b46b24a42468dda2f2ebcc3eba271c28d.tar.bz2 | |
Try to fix test_tarfile issues on Windows buildbots by closing file
objects explicitly instead of letting them linger on.
Diffstat (limited to 'Lib/tarfile.py')
| -rw-r--r-- | Lib/tarfile.py | 8 | 
1 files changed, 7 insertions, 1 deletions
| diff --git a/Lib/tarfile.py b/Lib/tarfile.py index bf6129e..bfdba58 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1764,14 +1764,19 @@ class TarFile(object):          if fileobj is None:              fileobj = bltn_open(name, mode + "b") +            extfileobj = False +        else: +            extfileobj = True          try:              t = cls.taropen(name, mode,                  gzip.GzipFile(name, mode, compresslevel, fileobj),                  **kwargs)          except IOError: +            if not extfileobj: +                fileobj.close()              raise ReadError("not a gzip file") -        t._extfileobj = False +        t._extfileobj = extfileobj          return t      @classmethod @@ -1795,6 +1800,7 @@ class TarFile(object):          try:              t = cls.taropen(name, mode, fileobj, **kwargs)          except (IOError, EOFError): +            fileobj.close()              raise ReadError("not a bzip2 file")          t._extfileobj = False          return t | 
