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

JelleZijlstra <[email protected]>
Newsgroups gmane.comp.python.cvs
Message-ID <[email protected]>
https://github.com/python/cpython/commit/547722204edeaa23a583cb047cf2d35fca85a753
commit: 547722204edeaa23a583cb047cf2d35fca85a753
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: JelleZijlstra <[email protected]>
date: 2026-08-13T14:45:29Z
summary:

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

gh-141174: Test `get_annotations()` on wrapped cyclical `functools.partial` (GH-155663)

Test `get_annotations()` on wrapped cyclical `functools.partial`
(cherry picked from commit 5d3f02a5c339f03fc377bacd40a83eb9217ffddb)

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]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.