GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — `reprlib.recursive_repr` does not copy `__type_params__` · Issue #109818 · python/cpython

reprlib.recursive_repr does not copy __type_params__ #109818

New issue
Copy link
New issue
Copy link
Closed
Closed
reprlib.recursive_repr does not copy __type_params__#109818
Copy link
Assignees
sobolevn
Labels
3.12only security fixesonly security fixes3.13only security fixesonly security fixesstdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directorytype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sobolevn
sobolevn
opened on Sep 25, 2023
Issue body actions

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

  • gh-109818: reprlib.recursive_repr copies __type_params__ #109819
  • [3.12] gh-109818: reprlib.recursive_repr copies __type_params__ (… #109999

Activity

  1. sobolevn
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    stdlibStandard Library Python modules in the Lib/ directoryStandard Library Python modules in the Lib/ directory
    3.12only security fixesonly security fixes
    3.13only security fixesonly security fixes
    on Sep 25, 2023
  2. sobolevn
    self-assigned this
    on Sep 25, 2023
  3. sobolevn
    added a commit that references this issue on Sep 25, 2023

    pythongh-109818: `repllib.recursive_repr` copies `__type_params__`

    cc26fa4
  4. JelleZijlstra
    added 2 commits that reference this issue on Sep 28, 2023

    gh-109818: `reprlib.recursive_repr` copies `__type_params__` (#109819)

    f65f9e8

    [3.12] pythongh-109818: `reprlib.recursive_repr` copies `__type_param…

    3d8ce93
  5. csm10495
    added a commit that references this issue on Sep 29, 2023

    pythongh-109818: `reprlib.recursive_repr` copies `__type_params__` (p…

    6a8f67e
  6. Yhg1s
    added a commit that references this issue on Oct 2, 2023

    [3.12] gh-109818: `reprlib.recursive_repr` copies `__type_params__` (… (

    9be6a11
  7. hugovk commented on Nov 9, 2023

    @hugovk
    hugovk
    on Nov 9, 2023
    Member
    More actions

    Thanks for the issue and PRs!

    Little reminder to close issues when the PRs are merged :)

  8. hugovk
    closed this as completedon Nov 9, 2023
  9. Glyphack
    added a commit that references this issue on Sep 2, 2024

    pythongh-109818: `reprlib.recursive_repr` copies `__type_params__` (p…

    c79de98
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @sobolevn
    sobolevn

Labels

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

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.