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: get_type_hints regression for 3.9 and 3.10
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.10, Python 3.9
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: BTaskaya, gvanrossum, levkivskyi, lukasz.langa
Priority: normal Keywords:

Created on 2020-08-22 09:30 by BTaskaya, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
typing_fail.py BTaskaya, 2020-08-22 09:30
Messages (4)
msg375791 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-08-22 09:30
The attached script works perfectly fine under Python 3.8, but it crashes in 3.9/3.10.

$ ./py38/python typing_fail.py (3.8.5+)
{'a': <class 'int'>, 'b': <class 'int'>}
$ ./py39/python typing_fail.py (3.9.0rc1+)
[SNIP]
TypeError: 'NoneType' object is not subscriptable
$ ./cpython/python typing_fail.py (3.10.0a0)
[SNIP]
TypeError: 'NoneType' object is not subscriptable
msg375792 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-08-22 09:38
This looks like a problem with the __globals__ of the NamedTuple.__new__
msg375802 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2020-08-22 16:14
Not nice to snip the traceback.
msg377789 - (view) Author: Batuhan Taskaya (BTaskaya) * (Python committer) Date: 2020-10-01 23:31
Commit 3ff51d425ecd98b7ba5a12ca9f77eda73fbf9f53 set the __builtins__ to None in namedtuple's creation, but the problem is that it is causing harm when the point came to the point of getting type hints on typing.NamedTuple.__new__ (we had a test about it), I'm changing that test (in the PR 20434) to work directly with the namedtuple itself instead of __new__ (since the annotations get proxied).
History
Date User Action Args
2022-04-11 14:59:35adminsetgithub: 85779
2020-10-01 23:31:29BTaskayasetstatus: open -> closed
resolution: not a bug
messages: + msg377789

stage: resolved
2020-08-22 16:14:54gvanrossumsetmessages: + msg375802
2020-08-22 09:38:44BTaskayasetmessages: + msg375792
2020-08-22 09:30:38BTaskayasetcomponents: + Library (Lib)
versions: + Python 3.9, Python 3.10
2020-08-22 09:30:02BTaskayacreate