]> granicus.if.org Git - python/commitdiff
#10465: fix broken delegation in __getattr__ of _PaddedFile.
authorGeorg Brandl <georg@python.org>
Sat, 20 Nov 2010 11:25:01 +0000 (11:25 +0000)
committerGeorg Brandl <georg@python.org>
Sat, 20 Nov 2010 11:25:01 +0000 (11:25 +0000)
Lib/gzip.py
Lib/test/test_gzip.py
Misc/NEWS

index 21b140498f886b05ae4885b50a87bbd6f4171a7c..ba2149ebf970938c44998a54d3f84bdd264861ad 100644 (file)
@@ -98,7 +98,7 @@ class _PaddedFile:
         return self.file.seek(offset, whence)
 
     def __getattr__(self, name):
-        return getattr(name, self.file)
+        return getattr(self.file, name)
 
 
 class GzipFile(io.BufferedIOBase):
index 7f2e798a6fbfcdf3f29389199194f02f6c499201..8af6d2ba54b41c0fe9f034f586fd498558b79af4 100644 (file)
@@ -197,6 +197,12 @@ class TestGzip(unittest.TestCase):
                 self.assertTrue(hasattr(f, "name"))
                 self.assertEqual(f.name, self.filename)
 
+    def test_paddedfile_getattr(self):
+        self.test_write()
+        with gzip.GzipFile(self.filename, 'rb') as f:
+            self.assertTrue(hasattr(f.fileobj, "name"))
+            self.assertEqual(f.fileobj.name, self.filename)
+
     def test_mtime(self):
         mtime = 123456789
         with gzip.GzipFile(self.filename, 'w', mtime = mtime) as fWrite:
index 672d9183c8d58538d4d3d6428da5911d55e4910d..530cc6f4d9667e8841266cd739b7a32618e48fa7 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -117,6 +117,8 @@ Core and Builtins
 Library
 -------
 
+- Issue #10465: fix broken delegating of attributes by gzip._PaddedFile.
+
 - Issue #10356: hash(Decimal("sNaN")) now raises ValueError instead of
   TypeError.