summaryrefslogtreecommitdiffstats
path: root/Lib
diff options
context:
space:
mode:
Diffstat (limited to 'Lib')
-rw-r--r--Lib/test/test_capi/test_opt.py21
1 files changed, 20 insertions, 1 deletions
diff --git a/Lib/test/test_capi/test_opt.py b/Lib/test/test_capi/test_opt.py
index 25fc36d..e1aef21 100644
--- a/Lib/test/test_capi/test_opt.py
+++ b/Lib/test/test_capi/test_opt.py
@@ -210,6 +210,8 @@ class TestExecutorInvalidation(unittest.TestCase):
exe = get_first_executor(f)
self.assertIsNone(exe)
+
+@unittest.skipIf(os.getenv("PYTHON_UOPS_OPTIMIZE") == "0", "Needs uop optimizer to run.")
class TestUops(unittest.TestCase):
def test_basic_loop(self):
@@ -570,7 +572,7 @@ class TestUops(unittest.TestCase):
self.assertLessEqual(count, 2)
-@unittest.skipIf(os.getenv("PYTHONUOPSOPTIMIZE", default=0) == 0, "Needs uop optimizer to run.")
+@unittest.skipIf(os.getenv("PYTHON_UOPS_OPTIMIZE") == "0", "Needs uop optimizer to run.")
class TestUopsOptimization(unittest.TestCase):
def _run_with_optimizer(self, testfunc, arg):
@@ -890,5 +892,22 @@ class TestUopsOptimization(unittest.TestCase):
self.assertLessEqual(len(guard_both_float_count), 1)
self.assertIn("_COMPARE_OP_STR", uops)
+ def test_type_inconsistency(self):
+ def testfunc(n):
+ for i in range(n):
+ x = _test_global + _test_global
+ # Must be a real global else it won't be optimized to _LOAD_CONST_INLINE
+ global _test_global
+ _test_global = 0
+ _, ex = self._run_with_optimizer(testfunc, 16)
+ self.assertIsNone(ex)
+ _test_global = 1.2
+ _, ex = self._run_with_optimizer(testfunc, 16)
+ self.assertIsNotNone(ex)
+ uops = get_opnames(ex)
+ self.assertIn("_GUARD_BOTH_INT", uops)
+ self.assertIn("_BINARY_OP_ADD_INT", uops)
+
+
if __name__ == "__main__":
unittest.main()