]> granicus.if.org Git - python/commitdiff
Backout 308f3c1e36d3. This change (issue21044) does not need to be merged on
authorSerhiy Storchaka <storchaka@gmail.com>
Tue, 22 Jul 2014 07:39:59 +0000 (10:39 +0300)
committerSerhiy Storchaka <storchaka@gmail.com>
Tue, 22 Jul 2014 07:39:59 +0000 (10:39 +0300)
2.7, as the os.fdopen sets the name attribute to '<fdopen>' and not to the fd.

Lib/tarfile.py
Lib/test/test_tarfile.py
Misc/ACKS
Misc/NEWS

index db5ff7f9a4c148ac590a9b7e373e2b83fd82d36d..57ea877911b38df8c3f1d11088b82bf7675f9ebc 100644 (file)
@@ -1522,8 +1522,7 @@ class TarFile(object):
             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
index 7d13398e929713396e023b7636f6023f46c81ea4..ff3265fc0ee324e21102090b71b86288a6c6fef0 100644 (file)
@@ -1,7 +1,6 @@
 # -*- coding: iso-8859-15 -*-
 
 import sys
-import io
 import os
 import shutil
 import StringIO
@@ -290,49 +289,24 @@ class CommonReadTest(ReadTest):
 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 @@ class Bz2MiscReadTest(MiscReadTest):
     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"
index 7fcfae03e12994f1f013c56103a53d37f95d22dc..87164689e3edda9e022a10a64118a45e06da5f08 100644 (file)
--- a/Misc/ACKS
+++ b/Misc/ACKS
@@ -997,7 +997,6 @@ Mike Pall
 Todd R. Palmer
 Juan David Ibáñez Palomar
 Jan Palus
-Martin Panter
 Mathias Panzenböck
 M. Papillon
 Peter Parente
index 5dfeb829f389cadc3ac7b671803f82a1f2d9b7c3..a57a0e4f2040593c48658f2b9321d9bc590e9e2d 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -19,9 +19,6 @@ Library
 - 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.