changeset: 91760:51699f5f5430 branch: 2.7 user: Serhiy Storchaka date: Tue Jul 22 10:39:59 2014 +0300 files: Lib/tarfile.py Lib/test/test_tarfile.py Misc/ACKS Misc/NEWS description: Backout 308f3c1e36d3. This change (issue21044) does not need to be merged on 2.7, as the os.fdopen sets the name attribute to '' and not to the fd. diff -r a61c3d17fe4f -r 51699f5f5430 Lib/tarfile.py --- a/Lib/tarfile.py Tue Jul 22 10:28:36 2014 +0300 +++ b/Lib/tarfile.py Tue Jul 22 10:39:59 2014 +0300 @@ -1522,8 +1522,7 @@ fileobj = bltn_open(name, self._mode) self._extfileobj = False else: - if (name is None and hasattr(fileobj, "name") and - isinstance(fileobj.name, basestring)): + if name is None and hasattr(fileobj, "name"): name = fileobj.name if hasattr(fileobj, "mode"): self._mode = fileobj.mode diff -r a61c3d17fe4f -r 51699f5f5430 Lib/test/test_tarfile.py --- a/Lib/test/test_tarfile.py Tue Jul 22 10:28:36 2014 +0300 +++ b/Lib/test/test_tarfile.py Tue Jul 22 10:39:59 2014 +0300 @@ -1,7 +1,6 @@ # -*- coding: iso-8859-15 -*- import sys -import io import os import shutil import StringIO @@ -290,49 +289,24 @@ class MiscReadTest(CommonReadTest): taropen = tarfile.TarFile.taropen - def requires_name_attribute(self): - pass - def test_no_name_argument(self): - self.requires_name_attribute() - with open(self.tarname, "rb") as fobj: - self.assertIsInstance(fobj.name, str) - with tarfile.open(fileobj=fobj, mode=self.mode) as tar: - self.assertIsInstance(tar.name, str) - self.assertEqual(tar.name, os.path.abspath(fobj.name)) + fobj = open(self.tarname, "rb") + tar = tarfile.open(fileobj=fobj, mode=self.mode) + self.assertEqual(tar.name, os.path.abspath(fobj.name)) def test_no_name_attribute(self): data = open(self.tarname, "rb").read() fobj = StringIO.StringIO(data) self.assertRaises(AttributeError, getattr, fobj, "name") tar = tarfile.open(fileobj=fobj, mode=self.mode) - self.assertIsNone(tar.name) + self.assertEqual(tar.name, None) def test_empty_name_attribute(self): data = open(self.tarname, "rb").read() fobj = StringIO.StringIO(data) fobj.name = "" tar = tarfile.open(fileobj=fobj, mode=self.mode) - self.assertIsNone(tar.name) - - def test_int_name_attribute(self): - # Issue 21044: tarfile.open() should handle fileobj with an integer - # 'name' attribute. - fd = os.open(self.tarname, os.O_RDONLY) - with io.open(fd, 'rb') as fobj: - self.assertIsInstance(fobj.name, int) - with tarfile.open(fileobj=fobj, mode=self.mode) as tar: - self.assertIsNone(tar.name) - - @test_support.requires_unicode - def test_unicode_name_attribute(self): - self.requires_name_attribute() - tarname = unicode(self.tarname, test_support.TESTFN_ENCODING) - with io.open(tarname, 'rb') as fobj: - self.assertIsInstance(fobj.name, unicode) - with tarfile.open(fileobj=fobj, mode=self.mode) as tar: - self.assertIsInstance(tar.name, unicode) - self.assertEqual(tar.name, os.path.abspath(fobj.name)) + self.assertEqual(tar.name, None) def test_illegal_mode_arg(self): with open(tmpname, 'wb'): @@ -1694,8 +1668,6 @@ tarname = bz2name mode = "r:bz2" taropen = tarfile.TarFile.bz2open - def requires_name_attribute(self): - self.skipTest("BZ2File have no name attribute") class Bz2UstarReadTest(UstarReadTest): tarname = bz2name mode = "r:bz2" diff -r a61c3d17fe4f -r 51699f5f5430 Misc/ACKS --- a/Misc/ACKS Tue Jul 22 10:28:36 2014 +0300 +++ b/Misc/ACKS Tue Jul 22 10:39:59 2014 +0300 @@ -997,7 +997,6 @@ Todd R. Palmer Juan David Ibáñez Palomar Jan Palus -Martin Panter Mathias Panzenböck M. Papillon Peter Parente diff -r a61c3d17fe4f -r 51699f5f5430 Misc/NEWS --- a/Misc/NEWS Tue Jul 22 10:28:36 2014 +0300 +++ b/Misc/NEWS Tue Jul 22 10:39:59 2014 +0300 @@ -19,9 +19,6 @@ - Issue #21868: Prevent turtle crash when undo buffer set to a value less than one. -- Issue #21044: tarfile.open() now handles fileobj with an integer 'name' - attribute. Based on patch by Martin Panter. - - Issue #21151: Fixed a segfault in the _winreg module when ``None`` is passed as a ``REG_BINARY`` value to SetValueEx. Patch by John Ehresman.