mirror of https://github.com/python/cpython
gh-109818: `reprlib.recursive_repr` copies `__type_params__` (#109819)
This commit is contained in:
parent
5bb6f0fcba
commit
f65f9e80fe
|
@ -29,6 +29,7 @@ def recursive_repr(fillvalue='...'):
|
|||
wrapper.__name__ = getattr(user_function, '__name__')
|
||||
wrapper.__qualname__ = getattr(user_function, '__qualname__')
|
||||
wrapper.__annotations__ = getattr(user_function, '__annotations__', {})
|
||||
wrapper.__type_params__ = getattr(user_function, '__type_params__', ())
|
||||
wrapper.__wrapped__ = user_function
|
||||
return wrapper
|
||||
|
||||
|
|
|
@ -774,5 +774,16 @@ class TestRecursiveRepr(unittest.TestCase):
|
|||
|
||||
self.assertIs(X.f, X.__repr__.__wrapped__)
|
||||
|
||||
def test__type_params__(self):
|
||||
class My:
|
||||
@recursive_repr()
|
||||
def __repr__[T: str](self, default: T = '') -> str:
|
||||
return default
|
||||
|
||||
type_params = My().__repr__.__type_params__
|
||||
self.assertEqual(len(type_params), 1)
|
||||
self.assertEqual(type_params[0].__name__, 'T')
|
||||
self.assertEqual(type_params[0].__bound__, str)
|
||||
|
||||
if __name__ == "__main__":
|
||||
unittest.main()
|
||||
|
|
|
@ -0,0 +1,2 @@
|
|||
Fix :func:`reprlib.recursive_repr` not copying ``__type_params__`` from
|
||||
decorated function.
|
Loading…
Reference in New Issue