diff options
author | Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> | 2023-06-06 14:06:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-06 14:06:44 (GMT) |
commit | 2d9ead219e940d3fd717cdb0841cfe8a97efe554 (patch) | |
tree | 14798a67f104cd7533a1e5ac54baeb8040a748b8 /Lib | |
parent | 260ba1fcdba860ab298c530af8c5340eb8b2c021 (diff) | |
download | cpython-2d9ead219e940d3fd717cdb0841cfe8a97efe554.zip cpython-2d9ead219e940d3fd717cdb0841cfe8a97efe554.tar.gz cpython-2d9ead219e940d3fd717cdb0841cfe8a97efe554.tar.bz2 |
[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 601ae09f0c8eda213b9050892f5ce9b91f0aa522)
Co-authored-by: Mark Shannon <mark@hotpy.org>
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) |