[Python-checkins] r86555 - in python/branches/py3k: Lib/gzip.py Lib/test/test_gzip.py Misc/NEWS

georg.brandl python-checkins at python.org
Sat Nov 20 12:25:02 CET 2010


Author: georg.brandl
Date: Sat Nov 20 12:25:01 2010
New Revision: 86555

Log:
#10465: fix broken delegation in __getattr__ of _PaddedFile.

Modified:
   python/branches/py3k/Lib/gzip.py
   python/branches/py3k/Lib/test/test_gzip.py
   python/branches/py3k/Misc/NEWS

Modified: python/branches/py3k/Lib/gzip.py
==============================================================================
--- python/branches/py3k/Lib/gzip.py	(original)
+++ python/branches/py3k/Lib/gzip.py	Sat Nov 20 12:25:01 2010
@@ -98,7 +98,7 @@
         return self.file.seek(offset, whence)
 
     def __getattr__(self, name):
-        return getattr(name, self.file)
+        return getattr(self.file, name)
 
 
 class GzipFile(io.BufferedIOBase):

Modified: python/branches/py3k/Lib/test/test_gzip.py
==============================================================================
--- python/branches/py3k/Lib/test/test_gzip.py	(original)
+++ python/branches/py3k/Lib/test/test_gzip.py	Sat Nov 20 12:25:01 2010
@@ -197,6 +197,12 @@
                 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:

Modified: python/branches/py3k/Misc/NEWS
==============================================================================
--- python/branches/py3k/Misc/NEWS	(original)
+++ python/branches/py3k/Misc/NEWS	Sat Nov 20 12:25:01 2010
@@ -117,6 +117,8 @@
 Library
 -------
 
+- Issue #10465: fix broken delegating of attributes by gzip._PaddedFile.
+
 - Issue #10356: hash(Decimal("sNaN")) now raises ValueError instead of
   TypeError.
 


More information about the Python-checkins mailing list