From 8d8dd804e34416cfdb5f70dffb7edbb21bb1246a Mon Sep 17 00:00:00 2001 From: dr-carlos Date: Thu, 13 Aug 2026 18:39:45 +0930 Subject: [PATCH] Test `get_annotations()` on wrapped cyclical `functools.partial` --- Lib/test/test_annotationlib.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Lib/test/test_annotationlib.py b/Lib/test/test_annotationlib.py index 5087c3ca425f1fc..b86b94d5b5c87dd 100644 --- a/Lib/test/test_annotationlib.py +++ b/Lib/test/test_annotationlib.py @@ -654,6 +654,13 @@ def f(x: 'int') -> 'str': ... result = get_annotations(f, eval_str=True) self.assertEqual(result, {'x': int, 'return': str}) + def test_eval_str_wrapped_partial_cycle_self(self): + def f(x: 'int') -> 'str': ... + f.__wrapped__ = functools.partial(f, 0) + # Cycle is detected and broken; globals from f itself are used. + result = get_annotations(f, eval_str=True) + self.assertEqual(result, {'x': int, 'return': str}) + def test_eval_str_wrapped_cycle_mutual(self): # gh-146556: mutual __wrapped__ cycle (a -> b -> a) must not hang. def a(x: 'int'): ...