In Lib/annotationlib.py, get_annotations() has an early-return guard at line 1010:
ifnoteval_str:
returndict(ann) # fast path, skips unwrap entirely for default eval_str=False
When eval_str=True the code falls through to a while True: loop (lines 1039–1048)
that unwraps __wrapped__ chains with no cycle detection:
ifunwrapisnotNone:
whileTrue:
ifhasattr(unwrap, "__wrapped__"):
unwrap=unwrap.__wrapped__# no cycle detectioncontinueiffunctools:=sys.modules.get("functools"):
ifisinstance(unwrap, functools.partial):
unwrap=unwrap.func# also no cycle detectioncontinuebreak
Fix
Apply the same cycle-detection pattern used by inspect.unwrap() (visited id-set):
Activity
gh-146556: Fix infinite loop in annotationlib.get_annotations() on ci…
pythongh-146556: Fix infinite loop in annotationlib.get_annotations()…
[3.14] gh-146556: Fix infinite loop in annotationlib.get_annotations(…
Merge remote-tracking branch 'upstream/main' into tachyon-ndjson-kole…
pythongh-146556: Fix infinite loop in annotationlib.get_annotations()…
pythongh-146556: Fix infinite loop in annotationlib.get_annotations()…