diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2016-04-26 06:31:11 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2016-04-26 06:31:11 (GMT) |
commit | cd9b5c2f4062860d614875e5943ce5e7fc9436ed (patch) | |
tree | bb21e78d3f91e57f34f8e10fcfdc2fef1a6334c1 | |
parent | 144da4ec850583c51e1c9cf55d8aaf20cdc7af5d (diff) | |
parent | b3b366d803207eb580a315a2b49733f100e92e89 (diff) | |
download | cpython-cd9b5c2f4062860d614875e5943ce5e7fc9436ed.zip cpython-cd9b5c2f4062860d614875e5943ce5e7fc9436ed.tar.gz cpython-cd9b5c2f4062860d614875e5943ce5e7fc9436ed.tar.bz2 |
Issue #26634: recursive_repr() now sets __qualname__ of wrapper.
Patch by Xiang Zhang.
-rw-r--r-- | Lib/reprlib.py | 1 | ||||
-rw-r--r-- | Lib/test/test_reprlib.py | 14 | ||||
-rw-r--r-- | Misc/NEWS | 3 |
3 files changed, 18 insertions, 0 deletions
diff --git a/Lib/reprlib.py b/Lib/reprlib.py index ecbd2cc..40d991f 100644 --- a/Lib/reprlib.py +++ b/Lib/reprlib.py @@ -30,6 +30,7 @@ def recursive_repr(fillvalue='...'): wrapper.__module__ = getattr(user_function, '__module__') wrapper.__doc__ = getattr(user_function, '__doc__') wrapper.__name__ = getattr(user_function, '__name__') + wrapper.__qualname__ = getattr(user_function, '__qualname__') wrapper.__annotations__ = getattr(user_function, '__annotations__', {}) return wrapper diff --git a/Lib/test/test_reprlib.py b/Lib/test/test_reprlib.py index a51c4d7..4bf9194 100644 --- a/Lib/test/test_reprlib.py +++ b/Lib/test/test_reprlib.py @@ -374,6 +374,13 @@ class MyContainer2(MyContainer): def __repr__(self): return '<' + ', '.join(map(str, self.values)) + '>' +class MyContainer3: + def __repr__(self): + 'Test document content' + pass + wrapped = __repr__ + wrapper = recursive_repr()(wrapped) + class TestRecursiveRepr(unittest.TestCase): def test_recursive_repr(self): m = MyContainer(list('abcde')) @@ -387,5 +394,12 @@ class TestRecursiveRepr(unittest.TestCase): m.append(m) self.assertEqual(repr(m), '<a, b, c, d, e, +++, x, +++>') + def test_assigned_attributes(self): + from functools import WRAPPER_ASSIGNMENTS as assigned + wrapped = MyContainer3.wrapped + wrapper = MyContainer3.wrapper + for name in assigned: + self.assertIs(getattr(wrapper, name), getattr(wrapped, name)) + if __name__ == "__main__": unittest.main() @@ -256,6 +256,9 @@ Core and Builtins Library ------- +- Issue #26634: recursive_repr() now sets __qualname__ of wrapper. Patch by + Xiang Zhang. + - Issue #26804: urllib.request will prefer lower_case proxy environment variables over UPPER_CASE or Mixed_Case ones. Patch contributed by Hans-Peter Jansen. |