Skip to content

reprlib.recursive_repr does not copy __type_params__ #109818

Closed
@sobolevn

Description

@sobolevn

Bug report

Repro:

>>> from reprlib import recursive_repr
>>> 
>>> class My:
...    @recursive_repr()
...    def __repr__[T](self, converter: T | None = None): ...
... 
>>> My().__repr__.__type_params__
()

This happens because recursive_repr does not use @wraps, but reinvents it:

cpython/Lib/reprlib.py

Lines 26 to 33 in f2eaa92

# Can't use functools.wraps() here because of bootstrap issues
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__', {})
wrapper.__wrapped__ = user_function
return wrapper

And __type_params__ was added in #104600

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security fixesstdlibPython modules in the Lib dirtype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions