jaltmayerpizzorno · GitHub

Bug report

Bug description:

With Python 3.12, this code generates a PY_UNWIND event; with 3.13 and later, it no longer does.

import sys
def gen():
    yield 1
    yield 2
def callback(code, off, exc):
    if code is gen.__code__:
        print("got unwind!")
ID=3
sysmon = sys.monitoring
sysmon.use_tool_id(ID, "test")
sysmon.register_callback(ID, sysmon.events.PY_UNWIND, callback)
sysmon.set_events(ID, sysmon.events.PY_UNWIND)
g = gen()
next(g)
del g  # or g.close()

CPython versions tested on:

3.13, 3.14

Operating systems tested on:

macOS, Linux

Linked PRs

Read the original on github.com ↗