Skip to content

reprlib.recursive_repr does not copy __type_params__ #109818

Description

@sobolevn

Bug report

Repro:

>>>fromreprlibimportrecursive_repr>>>>>>classMy:
... @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:

# 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
returnwrapper

And __type_params__ was added in #104600

Linked PRs

Metadata

Metadata

Assignees

Labels

3.12only security fixes3.13bugs and security fixesstdlibStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions