diff options
author | Mark Shannon <mark@hotpy.org> | 2024-04-25 11:32:47 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-25 11:32:47 +0100 |
commit | f180b31e7629d36265fa36f1560365358b4fd47c (patch) | |
tree | 3a887125f428f481fd85753d3f6b896843e84b3a /Lib/test/test_capi/test_opt.py | |
parent | 10bb90ed49a81a525b126ce8e4d8564c1616d0b3 (diff) | |
download | cpython-f180b31e7629d36265fa36f1560365358b4fd47c.tar.gz cpython-f180b31e7629d36265fa36f1560365358b4fd47c.zip |
GH-118095: Handle `RETURN_GENERATOR` in tier 2 (GH-118180)
Diffstat (limited to 'Lib/test/test_capi/test_opt.py')
-rw-r--r-- | Lib/test/test_capi/test_opt.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py index c004f463770..e2e772a52d7 100644 --- a/Lib/test/test_capi/test_opt.py +++ b/Lib/test/test_capi/test_opt.py @@ -1286,5 +1286,17 @@ class TestUopsOptimization(unittest.TestCase): self.assertEqual(res, 32 * 32) self.assertIsNone(ex) + def test_return_generator(self): + def gen(): + yield None + def testfunc(n): + for i in range(n): + gen() + return i + res, ex = self._run_with_optimizer(testfunc, 20) + self.assertEqual(res, 19) + self.assertIsNotNone(ex) + self.assertIn("_RETURN_GENERATOR", get_opnames(ex)) + if __name__ == "__main__": unittest.main() |