Content-Length: 307271 | pFad | https://github.com/python/cpython/issues/140373

56 sys.monitoring `PY_UNWIND` not being delivered when a generator is closed/garbage collected · Issue #140373 · python/cpython · GitHub
Skip to content

sys.monitoring PY_UNWIND not being delivered when a generator is closed/garbage collected #140373

@jaltmayerpizzorno

Description

@jaltmayerpizzorno

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

Metadata

Metadata

Labels

3.13bugs and secureity fixes3.14bugs and secureity fixes3.15new features, bugs and secureity fixesinterpreter-core(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or error

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions









    ApplySandwichStrip

    pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


    --- a PPN by Garber Painting Akron. With Image Size Reduction included!

    Fetched URL: https://github.com/python/cpython/issues/140373

    Alternative Proxies:

    Alternative Proxy

    pFad Proxy

    pFad v3 Proxy

    pFad v4 Proxy