Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Python: Checkins

r76383 - in python/branches/py3k: Lib/tarfile.py Misc/NEWS

 

 

Python checkins RSS feed   Index | Next | Previous | View Threaded


python-checkins at python

Nov 18, 2009, 2:20 PM

Post #1 of 1 (135 views)
Permalink
r76383 - in python/branches/py3k: Lib/tarfile.py Misc/NEWS

Author: lars.gustaebel
Date: Wed Nov 18 21:29:25 2009
New Revision: 76383

Log:
Merged revisions 76381 via svnmerge from
svn+ssh://pythondev [at] svn/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.
........


Modified:
python/branches/py3k/ (props changed)
python/branches/py3k/Lib/tarfile.py
python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/tarfile.py
==============================================================================
--- python/branches/py3k/Lib/tarfile.py (original)
+++ python/branches/py3k/Lib/tarfile.py Wed Nov 18 21:29:25 2009
@@ -1549,27 +1549,33 @@
self.inodes = {} # dictionary caching the inodes of
# archive members already added

- if self.mode == "r":
- self.firstmember = None
- self.firstmember = self.next()
-
- if self.mode == "a":
- # Move to the end of the archive,
- # before the first empty block.
- self.firstmember = None
- while True:
- if self.next() is None:
- if self.offset > 0:
- self.fileobj.seek(self.fileobj.tell() - BLOCKSIZE)
- break
-
- if self.mode in "aw":
- self._loaded = True
-
- if self.pax_headers:
- buf = self.tarinfo.create_pax_global_header(self.pax_headers.copy())
- self.fileobj.write(buf)
- self.offset += len(buf)
+ try:
+ if self.mode == "r":
+ self.firstmember = None
+ self.firstmember = self.next()
+
+ if self.mode == "a":
+ # Move to the end of the archive,
+ # before the first empty block.
+ self.firstmember = None
+ while True:
+ if self.next() is None:
+ if self.offset > 0:
+ self.fileobj.seek(self.fileobj.tell() - BLOCKSIZE)
+ break
+
+ if self.mode in "aw":
+ self._loaded = True
+
+ if self.pax_headers:
+ 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

#--------------------------------------------------------------------------
# Below are the classmethods which act as alternate constructors to the

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS (original)
+++ python/branches/py3k/Misc/NEWS Wed Nov 18 21:29:25 2009
@@ -137,6 +137,9 @@
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.

_______________________________________________
Python-checkins mailing list
Python-checkins [at] python
http://mail.python.org/mailman/listinfo/python-checkins

Python checkins RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact Gossamer Threads
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.