[Python-checkins] r81663 - in python/trunk: Lib/tarfile.py Lib/test/test_tarfile.py Misc/NEWS
lars.gustaebel
python-checkins at python.org
Thu Jun 3 11:56:22 CEST 2010
Author: lars.gustaebel
Date: Thu Jun 3 11:56:22 2010
New Revision: 81663
Log:
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/trunk/Lib/tarfile.py
python/trunk/Lib/test/test_tarfile.py
python/trunk/Misc/NEWS
Modified: python/trunk/Lib/tarfile.py
==============================================================================
--- python/trunk/Lib/tarfile.py (original)
+++ python/trunk/Lib/tarfile.py Thu Jun 3 11:56:22 2010
@@ -1884,7 +1884,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 = 0L
Modified: python/trunk/Lib/test/test_tarfile.py
==============================================================================
--- python/trunk/Lib/test/test_tarfile.py (original)
+++ python/trunk/Lib/test/test_tarfile.py Thu Jun 3 11:56:22 2010
@@ -662,10 +662,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("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/trunk/Misc/NEWS
==============================================================================
--- python/trunk/Misc/NEWS (original)
+++ python/trunk/Misc/NEWS Thu Jun 3 11:56:22 2010
@@ -46,6 +46,9 @@
Library
-------
+- Issue #8833: tarfile created hard link entries with a size field != 0 by
+ mistake.
+
- Issue #1368247: set_charset (and therefore MIMEText) now automatically
encodes a unicode _payload to the output_charset.
More information about the Python-checkins
mailing list