diff options
author | Mark Shannon <mark@hotpy.org> | 2023-06-02 09:39:38 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-02 09:39:38 (GMT) |
commit | 601ae09f0c8eda213b9050892f5ce9b91f0aa522 (patch) | |
tree | eeaab360fa7f967076b35cd09b1de78c7b7f3d04 /Lib | |
parent | ee26ca13a129da8cf549409d0a1b2e892ff2b4ec (diff) | |
download | cpython-601ae09f0c8eda213b9050892f5ce9b91f0aa522.zip cpython-601ae09f0c8eda213b9050892f5ce9b91f0aa522.tar.gz cpython-601ae09f0c8eda213b9050892f5ce9b91f0aa522.tar.bz2 |
GH-105162: Account for `INSTRUMENTED_RESUME` in gen.close/throw. (GH-105187)
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_monitoring.py | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Lib/test/test_monitoring.py b/Lib/test/test_monitoring.py index 46b817d..ef4a79a 100644 --- a/Lib/test/test_monitoring.py +++ b/Lib/test/test_monitoring.py @@ -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) |