changeset: 101148:fb70ea8b7b2d parent: 101146:ad6be34ce8c9 parent: 101147:1f0369547b0e user: Serhiy Storchaka date: Tue Apr 26 09:31:11 2016 +0300 files: Misc/NEWS description: Issue #26634: recursive_repr() now sets __qualname__ of wrapper. Patch by Xiang Zhang. diff -r ad6be34ce8c9 -r fb70ea8b7b2d Lib/reprlib.py --- a/Lib/reprlib.py Tue Apr 26 01:56:50 2016 +0200 +++ b/Lib/reprlib.py Tue Apr 26 09:31:11 2016 +0300 @@ -30,6 +30,7 @@ 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 -r ad6be34ce8c9 -r fb70ea8b7b2d Lib/test/test_reprlib.py --- a/Lib/test/test_reprlib.py Tue Apr 26 01:56:50 2016 +0200 +++ b/Lib/test/test_reprlib.py Tue Apr 26 09:31:11 2016 +0300 @@ -374,6 +374,13 @@ 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 @@ m.append(m) self.assertEqual(repr(m), '') + 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() diff -r ad6be34ce8c9 -r fb70ea8b7b2d Misc/NEWS --- a/Misc/NEWS Tue Apr 26 01:56:50 2016 +0200 +++ b/Misc/NEWS Tue Apr 26 09:31:11 2016 +0300 @@ -256,6 +256,9 @@ 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.