From 9bcbe49ba1b84cdd97f576c8347a12afaa67f545 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20Gust=C3=A4bel?= Date: Thu, 3 Jun 2010 10:07:08 +0000 Subject: [PATCH] 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. ........ --- Lib/tarfile.py | 2 +- Lib/test/test_tarfile.py | 6 +++++- Misc/NEWS | 3 +++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/Lib/tarfile.py b/Lib/tarfile.py index 8c2d26b2e46..98ae12f4c01 100644 --- a/Lib/tarfile.py +++ b/Lib/tarfile.py @@ -1880,7 +1880,7 @@ class TarFile(object): 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 diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py index 786f57a9149..909b08cece8 100644 --- a/Lib/test/test_tarfile.py +++ b/Lib/test/test_tarfile.py @@ -617,10 +617,14 @@ class WriteTest(WriteTestBase): 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: diff --git a/Misc/NEWS b/Misc/NEWS index 70e3ceeee42..e4a848edab8 100644 --- a/Misc/NEWS +++ b/Misc/NEWS @@ -58,6 +58,9 @@ C-API 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.