diff --git a/Lib/test/test_capi/test_misc.py b/Lib/test/test_capi/test_misc.py index 09b2a720613711..3141900373fdb1 100644 --- a/Lib/test/test_capi/test_misc.py +++ b/Lib/test/test_capi/test_misc.py @@ -2517,6 +2517,21 @@ def testfunc(x): uops = {opname for opname, _ in ex} self.assertIn("UNPACK_SEQUENCE", uops) + def test_for_iter(self): + def testfunc(x): + for i in range(x): + i += 1 + + opt = _testinternalcapi.get_uop_optimizer() + + with temporary_optimizer(opt): + testfunc(10) + + ex = get_first_executor(testfunc.__code__) + self.assertIsNotNone(ex) + uops = {opname for opname, _ in ex} + self.assertIn("FOR_ITER_RANGE", uops) + if __name__ == "__main__": unittest.main()