Kaydet (Commit) 7cf2c804 authored tarafından 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.
........
üst 8920d957
...@@ -1565,27 +1565,33 @@ class TarFile(object): ...@@ -1565,27 +1565,33 @@ 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
if self.mode == "r": try:
self.firstmember = None if self.mode == "r":
self.firstmember = self.next() self.firstmember = None
self.firstmember = self.next()
if self.mode == "a":
# Move to the end of the archive, if self.mode == "a":
# before the first empty block. # Move to the end of the archive,
self.firstmember = None # before the first empty block.
while True: self.firstmember = None
if self.next() is None: while True:
if self.offset > 0: if self.next() is None:
self.fileobj.seek(- BLOCKSIZE, 1) if self.offset > 0:
break self.fileobj.seek(- BLOCKSIZE, 1)
break
if self.mode in "aw":
self._loaded = True if self.mode in "aw":
self._loaded = True
if self.pax_headers:
buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy()) if self.pax_headers:
self.fileobj.write(buf) buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy())
self.offset += len(buf) self.fileobj.write(buf)
self.offset += len(buf)
except:
if not self._extfileobj:
self.fileobj.close()
self.closed = True
raise
def _getposix(self): def _getposix(self):
return self.format == USTAR_FORMAT return self.format == USTAR_FORMAT
......
...@@ -26,6 +26,9 @@ Core and Builtins ...@@ -26,6 +26,9 @@ Core and Builtins
Library Library
------- -------
- Issue #7341: Close the internal file object in the TarFile constructor in
case of an error.
- Issue #7328: pydoc no longer corrupts sys.path when run with the '-m' switch - Issue #7328: pydoc no longer corrupts sys.path when run with the '-m' switch
- Issue #7318: multiprocessing now uses a timeout when it fails to establish - Issue #7318: multiprocessing now uses a timeout when it fails to establish
......
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