There was an error while loading. Please reload this page.
get_annotations()
functools.partial
1 parent 5dab490 commit 5d3f02aCopy full SHA for 5d3f02a
1 file changed
Lib/test/test_annotationlib.py
@@ -654,6 +654,13 @@ def f(x: 'int') -> 'str': ...
654
result = get_annotations(f, eval_str=True)
655
self.assertEqual(result, {'x': int, 'return': str})
656
657
+ def test_eval_str_wrapped_partial_cycle_self(self):
658
+ def f(x: 'int') -> 'str': ...
659
+ f.__wrapped__ = functools.partial(f, 0)
660
+ # Cycle is detected and broken; globals from f itself are used.
661
+ result = get_annotations(f, eval_str=True)
662
+ self.assertEqual(result, {'x': int, 'return': str})
663
+
664
def test_eval_str_wrapped_cycle_mutual(self):
665
# gh-146556: mutual __wrapped__ cycle (a -> b -> a) must not hang.
666
def a(x: 'int'): ...
0 commit comments