Skip to content

Commit 5477222

Browse files
[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 5d3f02a) Co-authored-by: dr-carlos <77367421+dr-carlos@users.noreply.github.com>
1 parent 767e6ad commit 5477222

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

Lib/test/test_annotationlib.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,13 @@ def f(x: 'int') -> 'str': ...
654654
result = get_annotations(f, eval_str=True)
655655
self.assertEqual(result, {'x': int, 'return': str})
656656

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+
657664
def test_eval_str_wrapped_cycle_mutual(self):
658665
# gh-146556: mutual __wrapped__ cycle (a -> b -> a) must not hang.
659666
def a(x: 'int'): ...

0 commit comments

Comments
 (0)