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 — `types.GenericAlias` has extra `__copy__` and `__deepcopy__` in `__dir__` · Issue #105487 · python/cpython

types.GenericAlias has extra __copy__ and __deepcopy__ in __dir__ #105487

New issue
Copy link
New issue
Copy link
Closed
Closed
types.GenericAlias has extra __copy__ and __deepcopy__ in __dir__#105487
Copy link
Labels
interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sobolevn
sobolevn
opened on Jun 8, 2023
Issue body actions

Repro:

>>> type A[X] = list[X]
>>> dir(A[int])
[..., '__copy__', '__deepcopy__', ...]

We can access all other attributes, but not __copy__ and __deepcopy__:

>>> A[int].__copy__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'types.GenericAlias' object has no attribute '__copy__'. Did you mean: '__doc__'?

>>> A[int].__deepcopy__
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
AttributeError: 'types.GenericAlias' object has no attribute '__deepcopy__'

I am not quite sure what is the right thing to do here 🤔

Linked PRs

  • gh-105487: Fix __dir__ entries of GenericAlias #138578
  • [3.14] gh-105487: Fix __dir__ entries of GenericAlias (GH-138578) #138629
  • [3.13] gh-105487: Fix __dir__ entries of GenericAlias (GH-138578) #138640

Activity

  1. sobolevn
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    topic-typing
    on Jun 8, 2023
  2. sobolevn
    added a commit that references this issue on Jun 8, 2023

    pythongh-105487: Change the `repr` of `ParamSpec` list of args in `Ge…

    3402de9
  3. hugovk commented on Nov 10, 2023

    @hugovk
    hugovk
    on Nov 10, 2023
    Member
    More actions

    Thanks for the fix!

  4. hugovk
    closed this as completedon Nov 10, 2023
  5. asottile-sentry commented on Sep 5, 2025

    @asottile-sentry
    asottile-sentry
    on Sep 5, 2025
    More actions

    a little late to the party but __bases__ appears to not work as well:

    >>> '__bases__' in dir(list[str])
    True
    >>> list[str].__bases__
    Traceback (most recent call last):
      File "<python-input-15>", line 1, in <module>
        list[str].__bases__
    AttributeError: 'types.GenericAlias' object has no attribute '__bases__'. Did you mean: '__args__'?
  6. sobolevn
    reopened this on Sep 6, 2025
  7. sobolevn
    added a commit that references this issue on Sep 6, 2025

    pythongh-105487: Fix `__dir__` entries of `GenericAlias`

    110e6b0
  8. sobolevn commented on Sep 6, 2025

    @sobolevn
    sobolevn
    on Sep 6, 2025
    MemberAuthor
    More actions

    Looks like the linked PR does something completely different. I created a new one.

  9. sobolevn commented on Sep 6, 2025

    @sobolevn
    sobolevn
    on Sep 6, 2025
    MemberAuthor
    More actions

    Thanks for the report!

  10. picnixz
    added
    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)
    on Sep 6, 2025
  11. sobolevn
    added 2 commits that reference this issue on Sep 6, 2025

    pythongh-105487: Fix `__dir__` entries of `GenericAlias`

    1eac463

    gh-105487: Fix `__dir__` entries of `GenericAlias` (#138578)

    b0420b5
  12. miss-islington
    added a commit that references this issue on Sep 7, 2025

    pythongh-105487: Fix `__dir__` entries of `GenericAlias` (pythonGH-13…

    200f76f
  13. sobolevn
    added 2 commits that reference this issue on Sep 8, 2025

    [3.13] pythongh-105487: Fix `__dir__` entries of `GenericAlias` (pyth…

    ee40172

    [3.13] gh-105487: Fix `__dir__` entries of `GenericAlias` (GH-138578) (…

    d3b6bb1
  14. lkollar
    added a commit that references this issue on Sep 9, 2025

    pythongh-105487: Fix `__dir__` entries of `GenericAlias` (python#138578)

    b42938b
  15. encukou
    added a commit that references this issue on Oct 7, 2025

    [3.14] gh-105487: Fix `__dir__` entries of `GenericAlias` (GH-138578) (…

    09fdd21
  16. hugovk
    closed this as completedon Jul 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)topic-typingtype-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 01402520 — 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.