Commit 355538e5 authored by Lars Gustäbel's avatar Lars Gustäbel

Issue #7341: Close the internal file object in the TarFile

constructor in case of an error.
parent c029942e
......@@ -1557,6 +1557,7 @@ class TarFile(object):
self.inodes = {} # dictionary caching the inodes of
# archive members already added
try:
if self.mode == "r":
self.firstmember = None
self.firstmember = self.next()
......@@ -1578,6 +1579,11 @@ class TarFile(object):
buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy())
self.fileobj.write(buf)
self.offset += len(buf)
except:
if not self._extfileobj:
self.fileobj.close()
self.closed = True
raise
def _getposix(self):
return self.format == USTAR_FORMAT
......
......@@ -440,6 +440,9 @@ Core and Builtins
Library
-------
- Issue #7341: Close the internal file object in the TarFile constructor in
case of an error.
- Issue #7293: distutils.test_msvc9compiler is fixed to work on any fresh
Windows box. Help provided by David Bolen.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment