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.

Title: Making instance of `TypeVar` fails because of missing `__name__`
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.9, Python 3.8, Python 3.7
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: hongweipeng, jack1142, levkivskyi, miss-islington
Priority: normal Keywords: patch

Created on 2020-03-12 00:11 by jack1142, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 19616 merged hongweipeng, 2020-04-20 07:45
PR 19626 merged miss-islington, 2020-04-20 20:04
PR 19627 merged miss-islington, 2020-04-20 20:04
Messages (4)
msg363990 - (view) Author: Jakub Kuczys (jack1142) * Date: 2020-03-12 00:11
Example code:
code = """
import typing
T = typing.TypeVar("T")
exec(code, {})

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<string>", line 3, in <module>
  File "C:\Python38\lib\", line 603, in __init__
    def_mod = sys._getframe(1).f_globals['__name__']  # for pickling
KeyError: '__name__'

If this problem with `__name__` is not something that needs to be fixed, then I also noticed that the same line in will also raise when platform doesn't have `sys._getframe()`
msg366872 - (view) Author: Ivan Levkivskyi (levkivskyi) * (Python committer) Date: 2020-04-20 20:02
New changeset a25a04fea5446b1712cde0cff556574be139285a by HongWeipeng in branch 'master':
bpo-39942:Fix failure in `TypeVar` when missing `__name__` (GH-19616)
msg366874 - (view) Author: miss-islington (miss-islington) Date: 2020-04-20 20:22
New changeset 694a95ff437613e6295f531336b5bc7cab9e3713 by Miss Islington (bot) in branch '3.7':
bpo-39942:Fix failure in `TypeVar` when missing `__name__` (GH-19616)
msg366876 - (view) Author: miss-islington (miss-islington) Date: 2020-04-20 20:24
New changeset 41660cac63c1a216e43335007e329e213054100e by Miss Islington (bot) in branch '3.8':
bpo-39942:Fix failure in `TypeVar` when missing `__name__` (GH-19616)
Date User Action Args
2022-04-11 14:59:28adminsetgithub: 84123
2020-04-20 20:28:52levkivskyisetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-04-20 20:24:42miss-islingtonsetmessages: + msg366876
2020-04-20 20:22:41miss-islingtonsetmessages: + msg366874
2020-04-20 20:04:38miss-islingtonsetpull_requests: + pull_request18955
2020-04-20 20:04:31miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request18954
2020-04-20 20:02:00levkivskyisetnosy: + levkivskyi
messages: + msg366872
2020-04-20 07:45:56hongweipengsetkeywords: + patch
nosy: + hongweipeng

pull_requests: + pull_request18948
stage: patch review
2020-03-12 00:11:51jack1142create