Traceback (most recent call last):
File "<string>", line 15, in <module>
File "<string>", line 10, in __len__
File "<string>", line 10, in __len__
File "<string>", line 10, in __len__
[Previous line repeated 496 more times]
RecursionError: maximum recursion depth exceeded
What happened?
iterator.__length_hint__holds its internalPyMutexwhile calling the sequence’s__len__. A user__len__can call back into the same__length_hint__, which immediately blocks on the already-held mutex and deadlocks the interpreter instead of raising an error or progressing the iterator.Proof of Concept:
Affected Versions
Python 3.13.0alpha (heads/main-dirty:21300f689, Dec 13 2025, 22:16:49) [RustPython 0.4.0 with rustc 1.90.0-nightly (11ad40bb8 2025-06-28)]Vulnerable Code
Rust Output
CPython Output