gh-141174: Test `get_annotations()` on wrapped cyclical `functools.partial` (#155663)
JelleZijlstra <[email protected]> Thu, 13 Aug 2026 10:17:48 -0400 (EDT)
| Newsgroups | gmane.comp.python.cvs |
|---|---|
| Message-ID | <[email protected]> |
https://github.com/python/cpython/commit/5d3f02a5c339f03fc377bacd40a83eb9217ffddb commit: 5d3f02a5c339f03fc377bacd40a83eb9217ffddb branch: main author: dr-carlos <[email protected]> committer: JelleZijlstra <[email protected]> date: 2026-08-13T14:17:21Z summary: gh-141174: Test `get_annotations()` on wrapped cyclical `functools.partial` (#155663) Test `get_annotations()` on wrapped cyclical `functools.partial` files: M Lib/test/test_annotationlib.py diff --git a/Lib/test/test_annotationlib.py b/Lib/test/test_annotationlib.py index 5bfcf5ce4131e3..23d31b05efea2a 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'): ... _______________________________________________ Python-checkins mailing list -- [email protected] To unsubscribe send an email to [email protected] https://mail.python.org/mailman3//lists/python-checkins.python.org Member address: [email protected]