Closed
Description
Crash report
What happened?
When CPython 3.12 is built with assertions enabled, the following snippet causes the interpreter to crash:
x = lambda: (yield 3)
next(x())
$ ./python /tmp/LambdasTest.py
python: Objects/genobject.c:400: gen_close: Assertion `exception_handler_depth > 0' failed.
Aborted (core dumped)
This doesn't happen with 3.11 or with main. From a quick bisect:
- [3.12] gh-100762: Fix optimization in gen_close (GH-111069) #115818 (eb4774d) broke it on 3.12
- gh-111354: simplify detection of RESUME after YIELD_VALUE at except-depth 1 #111459 (52cc4af) fixed it on main
This was triggered in the wild by Nuitka's test suite: Nuitka/Nuitka#2893.
CC @iritkatriel
CPython versions tested on:
3.12
Operating systems tested on:
Linux
Output from running 'python -VV' on the command line:
Python 3.12.3+ (heads/3.12:6d9677d78e, Jun 1 2024, 11:06:51) [GCC 14.1.1 20240516]