mirror of
https://github.com/python/cpython.git
synced 2025-08-09 11:29:45 +00:00
[3.12] GH-105162: Account for INSTRUMENTED_RESUME
in gen.close/throw. (GH-105187) (#105378)
GH-105162: Account for `INSTRUMENTED_RESUME` in gen.close/throw. (GH-105187)
(cherry picked from commit 601ae09f0c
)
Co-authored-by: Mark Shannon <mark@hotpy.org>
This commit is contained in:
parent
260ba1fcdb
commit
2d9ead219e
3 changed files with 52 additions and 3 deletions
|
@ -1425,3 +1425,38 @@ class TestUninitialized(unittest.TestCase, MonitoringTestBase):
|
|||
|
||||
def test_get_local_events_uninitialized(self):
|
||||
self.assertEqual(sys.monitoring.get_local_events(TEST_TOOL, self.f.__code__), 0)
|
||||
|
||||
class TestRegressions(MonitoringTestBase, unittest.TestCase):
|
||||
|
||||
def test_105162(self):
|
||||
caught = None
|
||||
|
||||
def inner():
|
||||
nonlocal caught
|
||||
try:
|
||||
yield
|
||||
except Exception:
|
||||
caught = "inner"
|
||||
yield
|
||||
|
||||
def outer():
|
||||
nonlocal caught
|
||||
try:
|
||||
yield from inner()
|
||||
except Exception:
|
||||
caught = "outer"
|
||||
yield
|
||||
|
||||
def run():
|
||||
gen = outer()
|
||||
gen.send(None)
|
||||
gen.throw(Exception)
|
||||
run()
|
||||
self.assertEqual(caught, "inner")
|
||||
caught = None
|
||||
try:
|
||||
sys.monitoring.set_events(TEST_TOOL, E.PY_RESUME)
|
||||
run()
|
||||
self.assertEqual(caught, "inner")
|
||||
finally:
|
||||
sys.monitoring.set_events(TEST_TOOL, 0)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue