mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
GH-105162: Account for INSTRUMENTED_RESUME
in gen.close/throw. (GH-105187)
This commit is contained in:
parent
ee26ca13a1
commit
601ae09f0c
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