[Python-checkins] r81666 - in python/branches/release31-maint: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS

lars.gustaebel python-checkins at python.org
Thu Jun 3 12:15:18 CEST 2010


Author: lars.gustaebel
Date: Thu Jun  3 12:15:18 2010
New Revision: 81666

Log:
Merged revisions 81665 via svnmerge from 
svn+ssh://pythondev@svn.python.org/python/branches/py3k

................
  r81665 | lars.gustaebel | 2010-06-03 12:11:52 +0200 (Thu, 03 Jun 2010) | 11 lines
  
  Merged revisions 81663 via svnmerge from 
  svn+ssh://pythondev@svn.python.org/python/trunk
  
  ........
    r81663 | lars.gustaebel | 2010-06-03 11:56:22 +0200 (Thu, 03 Jun 2010) | 4 lines
    
    Issue #8833: tarfile created hard link entries with a size
    field != 0 by mistake. The associated testcase did not
    expose this bug because it was broken too.
  ........
................


Modified:
   python/branches/release31-maint/   (props changed)
   python/branches/release31-maint/Lib/tarfile.py
   python/branches/release31-maint/Lib/test/test_tarfile.py
   python/branches/release31-maint/Misc/NEWS

Modified: python/branches/release31-maint/Lib/tarfile.py
==============================================================================
--- python/branches/release31-maint/Lib/tarfile.py	(original)
+++ python/branches/release31-maint/Lib/tarfile.py	Thu Jun  3 12:15:18 2010
@@ -1857,7 +1857,7 @@
         tarinfo.mode = stmd
         tarinfo.uid = statres.st_uid
         tarinfo.gid = statres.st_gid
-        if stat.S_ISREG(stmd):
+        if type == REGTYPE:
             tarinfo.size = statres.st_size
         else:
             tarinfo.size = 0

Modified: python/branches/release31-maint/Lib/test/test_tarfile.py
==============================================================================
--- python/branches/release31-maint/Lib/test/test_tarfile.py	(original)
+++ python/branches/release31-maint/Lib/test/test_tarfile.py	Thu Jun  3 12:15:18 2010
@@ -616,10 +616,14 @@
         if hasattr(os, "link"):
             link = os.path.join(TEMPDIR, "link")
             target = os.path.join(TEMPDIR, "link_target")
-            open(target, "wb").close()
+            fobj = open(target, "wb")
+            fobj.write(b"aaa")
+            fobj.close()
             os.link(target, link)
             try:
                 tar = tarfile.open(tmpname, self.mode)
+                # Record the link target in the inodes list.
+                tar.gettarinfo(target)
                 tarinfo = tar.gettarinfo(link)
                 self.assertEqual(tarinfo.size, 0)
             finally:

Modified: python/branches/release31-maint/Misc/NEWS
==============================================================================
--- python/branches/release31-maint/Misc/NEWS	(original)
+++ python/branches/release31-maint/Misc/NEWS	Thu Jun  3 12:15:18 2010
@@ -54,6 +54,9 @@
 Library
 -------
 
+- Issue #8833: tarfile created hard link entries with a size field != 0 by
+  mistake.
+
 - Charset.body_encode now correctly handles base64 encoding by encoding
   with the output_charset before calling base64mime.encode.  Passes the
   tests from 2.x issue 1368247.


More information about the Python-checkins mailing list