This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: resolve_bases() and new_class() do not work with type alias of a built-in type
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: gvanrossum, kj, miss-islington, serhiy.storchaka, yselivanov
Priority: normal Keywords: patch

Created on 2021-10-28 20:38 by serhiy.storchaka, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29298 merged serhiy.storchaka, 2021-10-28 20:44
PR 29927 merged miss-islington, 2021-12-05 20:44
PR 29928 merged miss-islington, 2021-12-05 20:44
Messages (4)
msg405265 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-10-28 20:38
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].
msg407740 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-12-05 20:44
New changeset 2b318ce1c988b7b6e3caf293d55f289e066b6e0f by Serhiy Storchaka in branch 'main':
bpo-45664: Fix resolve_bases() and new_class() for GenericAlias instance as a base (GH-29298)
https://github.com/python/cpython/commit/2b318ce1c988b7b6e3caf293d55f289e066b6e0f
msg407746 - (view) Author: miss-islington (miss-islington) Date: 2021-12-05 21:26
New changeset cb68c0a3a4aeb4ec58ab1f71b70bc8bfecbceef6 by Miss Islington (bot) in branch '3.10':
bpo-45664: Fix resolve_bases() and new_class() for GenericAlias instance as a base (GH-29298)
https://github.com/python/cpython/commit/cb68c0a3a4aeb4ec58ab1f71b70bc8bfecbceef6
msg407926 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2021-12-07 12:00
New changeset bffce2cbb5543bc63a67e33ad599328a12f2b00a 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)
https://github.com/python/cpython/commit/bffce2cbb5543bc63a67e33ad599328a12f2b00a
History
Date User Action Args
2022-04-11 14:59:51adminsetgithub: 89827
2021-12-07 12:00:37serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-12-07 12:00:11serhiy.storchakasetmessages: + msg407926
2021-12-06 12:41:59CharStringsetnosy: - CharString, CharString
2021-12-05 21:26:46miss-islingtonsetmessages: + msg407746
2021-12-05 20:44:12miss-islingtonsetpull_requests: + pull_request28152
2021-12-05 20:44:08serhiy.storchakasetmessages: + msg407740
2021-12-05 20:44:08miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request28151
2021-10-29 13:49:38kjsetpull_requests: - pull_request27577
2021-10-29 11:01:00CharStringsetpull_requests: + pull_request27577
2021-10-29 08:41:23serhiy.storchakalinkissue45665 dependencies
2021-10-29 08:25:09serhiy.storchakasetpull_requests: - pull_request27570
2021-10-29 08:25:02serhiy.storchakasetpull_requests: - pull_request27569
2021-10-29 03:32:22CharStringsetnosy: + CharString
pull_requests: + pull_request27570
2021-10-29 03:32:22CharStringsetnosy: + CharString
pull_requests: + pull_request27569
2021-10-28 20:44:17serhiy.storchakasetkeywords: + patch
stage: patch review
pull_requests: + pull_request27562
2021-10-28 20:38:27serhiy.storchakacreate