Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reprlib.recursive_repr is not setting .__wrapped__ attribute #107409

Closed
denballakh opened this issue Jul 28, 2023 · 0 comments · Fixed by #107410
Closed

reprlib.recursive_repr is not setting .__wrapped__ attribute #107409

denballakh opened this issue Jul 28, 2023 · 0 comments · Fixed by #107410
Labels
type-bug An unexpected behavior, bug, or error

Comments

@denballakh
Copy link
Contributor

denballakh commented Jul 28, 2023

Bug report

There is no way to get original actual __repr__ function after applying @recursive_repr decorator

import reprlib
class X:
    @reprlib.recursive_repr()
    def __repr__(self) -> str:
        return f'X({self.__dict__})'

# how to get initial X.__repr__ back?
# this doesn't work:
X.__repr__.__wrapped__ # AttributeError: 'function' object has no attribute '__wrapped__'
# this is awful:
X.__repr__.__closure__[2].cell_contents

Your environment

  • CPython versions tested on: 3.11, 3.13.0a0

Linked PRs

@denballakh denballakh added the type-bug An unexpected behavior, bug, or error label Jul 28, 2023
kumaraditya303 added a commit that referenced this issue Aug 10, 2023
…107410)

Co-authored-by: Kumar Aditya <kumaraditya@python.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant