https://github.com/python/cpython/commit/94aa79c77a412fe5842aa105509fb0cac71a4e72
commit: 94aa79c77a412fe5842aa105509fb0cac71a4e72
branch: 3.15
author: Miss Islington (bot) <[email protected]>
committer: hugovk <[email protected]>
date: 2026-08-27T15:47:07+03:00
summary:

[3.15] gh-141174: Test `get_annotations()` on wrapped cyclical 
`functools.partial` (GH-155663) (#155709)

Co-authored-by: dr-carlos <[email protected]>

files:
M Lib/test/test_annotationlib.py

diff --git a/Lib/test/test_annotationlib.py b/Lib/test/test_annotationlib.py
index eabdbdd59fb87b..530114161701b5 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]

Reply via email to