From 9f1c1dcde30305c4ed68b296ca96028ea7123152 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 20 Nov 2010 11:25:01 +0000 Subject: #10465: fix broken delegation in __getattr__ of _PaddedFile. --- Lib/gzip.py | 2 +- Lib/test/test_gzip.py | 6 ++++++ Misc/NEWS | 2 ++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/Lib/gzip.py b/Lib/gzip.py index 21b1404..ba2149e 100644 --- a/Lib/gzip.py +++ b/Lib/gzip.py @@ -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): diff --git a/Lib/test/test_gzip.py b/Lib/test/test_gzip.py index 7f2e798..8af6d2b 100644 --- a/Lib/test/test_gzip.py +++ b/Lib/test/test_gzip.py @@ -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: diff --git a/Misc/NEWS b/Misc/NEWS index 672d918..530cc6f 100644 --- 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. -- cgit v0.12