mirror of
https://github.com/python/cpython.git
synced 2025-08-03 08:34:29 +00:00
bpo-41341: Recursive evaluation of ForwardRef in get_type_hints (GH-21553)
The issue raised by recursive evaluation is infinite recursion with
recursive types. In that case, only the first recursive ForwardRef is
evaluated.
(cherry picked from commit 653f420b53
)
Co-authored-by: wyfo <joperez@hotmail.fr>
This commit is contained in:
parent
8b7544cd02
commit
41d1c04f73
3 changed files with 21 additions and 6 deletions
|
@ -2456,6 +2456,12 @@ class ForwardRefTests(BaseTestCase):
|
|||
self.assertEqual(get_type_hints(foo, globals(), locals()),
|
||||
{'a': tuple[T]})
|
||||
|
||||
def test_double_forward(self):
|
||||
def foo(a: 'List[\'int\']'):
|
||||
pass
|
||||
self.assertEqual(get_type_hints(foo, globals(), locals()),
|
||||
{'a': List[int]})
|
||||
|
||||
def test_forward_recursion_actually(self):
|
||||
def namespace1():
|
||||
a = typing.ForwardRef('A')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue