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

resolve_bases() and new_class() do not work with type alias of a built-in type #89827

Closed
Tracked in #89828
serhiy-storchaka opened this issue Oct 28, 2021 · 4 comments
Closed
Tracked in #89828
Labels
3.9 3.10 3.11 stdlib type-bug

Comments

@serhiy-storchaka
Copy link
Member

@serhiy-storchaka serhiy-storchaka commented Oct 28, 2021

BPO 45664
Nosy @gvanrossum, @serhiy-storchaka, @1st1, @miss-islington, @Fidget-Spinner
PRs
  • #29298
  • #29927
  • #29928
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-12-07.12:00:37.234>
    created_at = <Date 2021-10-28.20:38:27.785>
    labels = ['type-bug', 'library', '3.9', '3.10', '3.11']
    title = 'resolve_bases() and new_class() do not work with type alias of a built-in type'
    updated_at = <Date 2021-12-07.12:00:37.234>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2021-12-07.12:00:37.234>
    actor = 'serhiy.storchaka'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-12-07.12:00:37.234>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2021-10-28.20:38:27.785>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 45664
    keywords = ['patch']
    message_count = 4.0
    messages = ['405265', '407740', '407746', '407926']
    nosy_count = 5.0
    nosy_names = ['gvanrossum', 'serhiy.storchaka', 'yselivanov', 'miss-islington', 'kj']
    pr_nums = ['29298', '29927', '29928']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue45664'
    versions = ['Python 3.9', 'Python 3.10', 'Python 3.11']

    @serhiy-storchaka
    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented Oct 28, 2021

    resolve_bases() returns incorrect result:

    >>> import types
    >>> types.resolve_bases((list[int],))
    (list[int],)

    Expected (list,).

    new_class() fails:

    >>> types.new_class('L', (list[int],), {})
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/home/serhiy/py/cpython/Lib/types.py", line 77, in new_class
        return meta(name, resolved_bases, ns, **kwds)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    TypeError: GenericAlias expected 2 arguments, got 3

    Both work well with typing.List[int].

    @serhiy-storchaka serhiy-storchaka added 3.9 3.10 3.11 stdlib type-bug labels Oct 28, 2021
    @serhiy-storchaka
    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented Dec 5, 2021

    New changeset 2b318ce by Serhiy Storchaka in branch 'main':
    bpo-45664: Fix resolve_bases() and new_class() for GenericAlias instance as a base (GH-29298)
    2b318ce

    @miss-islington
    Copy link
    Contributor

    @miss-islington miss-islington commented Dec 5, 2021

    New changeset cb68c0a by Miss Islington (bot) in branch '3.10':
    bpo-45664: Fix resolve_bases() and new_class() for GenericAlias instance as a base (GH-29298)
    cb68c0a

    @serhiy-storchaka
    Copy link
    Member Author

    @serhiy-storchaka serhiy-storchaka commented Dec 7, 2021

    New changeset bffce2c by Miss Islington (bot) in branch '3.9':
    bpo-45664: Fix resolve_bases() and new_class() for GenericAlias instance as a base (GH-29298) (GH-29928)
    bffce2c

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 3.10 3.11 stdlib type-bug
    Projects
    None yet
    Development

    No branches or pull requests

    2 participants