Commit 7b465390 authored by Lars Gustäbel's avatar Lars Gustäbel

Merged revisions 76381 via svnmerge from

svn+ssh://pythondev@svn.python.org/python/trunk

........
  r76381 | lars.gustaebel | 2009-11-18 21:24:54 +0100 (Wed, 18 Nov 2009) | 3 lines

  Issue #7341: Close the internal file object in the TarFile
  constructor in case of an error.
........
parent fe267ac7
...@@ -1549,6 +1549,7 @@ class TarFile(object): ...@@ -1549,6 +1549,7 @@ class TarFile(object):
self.inodes = {} # dictionary caching the inodes of self.inodes = {} # dictionary caching the inodes of
# archive members already added # archive members already added
try:
if self.mode == "r": if self.mode == "r":
self.firstmember = None self.firstmember = None
self.firstmember = self.next() self.firstmember = self.next()
...@@ -1570,6 +1571,11 @@ class TarFile(object): ...@@ -1570,6 +1571,11 @@ class TarFile(object):
buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy()) buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy())
self.fileobj.write(buf) self.fileobj.write(buf)
self.offset += len(buf) self.offset += len(buf)
except:
if not self._extfileobj:
self.fileobj.close()
self.closed = True
raise
#-------------------------------------------------------------------------- #--------------------------------------------------------------------------
# Below are the classmethods which act as alternate constructors to the # Below are the classmethods which act as alternate constructors to the
......
...@@ -137,6 +137,9 @@ C-API ...@@ -137,6 +137,9 @@ C-API
Library 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 - Issue #7293: distutils.test_msvc9compiler is fixed to work on any fresh
Windows box. Help provided by David Bolen. 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