GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — `for` loop swallows exceptions raised by a `sys.monitoring` callback for `StopIteration` · Issue #160676 · python/cpython Open Labels interpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error DescriptionBug reportWhen a ReproducerSave as import sys class Empty: def __iter__(self): return self def __next__(self): raise StopIteration def run(): for _ in Empty(): pass def on_raise(code, offset, exc): if code is run.__code__ and isinstance(exc, StopIteration): print("callback: raising RuntimeError") raise RuntimeError("monitor callback failed") monitoring = sys.monitoring monitoring.use_tool_id(3, "stopiteration-repro") try: monitoring.register_callback(3, monitoring.events.RAISE, on_raise) monitoring.set_events(3, monitoring.events.RAISE) run() finally: monitoring.set_events(3, 0) monitoring.register_callback(3, monitoring.events.RAISE, None) monitoring.free_tool_id(3) raise AssertionError("RuntimeError from the monitoring callback was swallowed") Expected behavior
Actual behaviorThe callback prints: However, Replacing the loop in CPython versions tested on:CPython main branch, 3.16, 3.15, 3.14 Operating systems tested on:Linux, macOS Linked PRsActivity
MetadataMetadataAssigneesLabelsinterpreter-core(Objects, Python, Grammar, and Parser dirs)(Objects, Python, Grammar, and Parser dirs)type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error ProjectsMilestoneRelationshipsDevelopmentIssue actions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |