Skip to content

Commit 13aad7b

Browse files
add test
1 parent f722179 commit 13aad7b

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

Lib/test/test_capi/test_opt.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5039,6 +5039,20 @@ def testfunc(n):
50395039
uops = get_opnames(ex)
50405040
self.assertNotIn("_LOAD_SUPER_ATTR_METHOD", uops)
50415041
self.assertEqual(uops.count("_GUARD_NOS_TYPE_VERSION"), 2)
5042+
exe = get_first_executor(testfunc)
5043+
self.assertIsNotNone(exe)
5044+
self.assertTrue(exe.is_valid())
5045+
# this should change the type version of A, which should invalidate the executor
5046+
A.method1 = lambda self: 1
5047+
self.assertFalse(exe.is_valid())
5048+
# re-running should create a new executor
5049+
res, ex = self._run_with_optimizer(testfunc, 2 * TIER2_THRESHOLD)
5050+
self.assertEqual(res, 2 * 22 * TIER2_THRESHOLD)
5051+
self.assertIsNotNone(ex)
5052+
uops = get_opnames(ex)
5053+
self.assertNotIn("_LOAD_SUPER_ATTR_METHOD", uops)
5054+
self.assertEqual(uops.count("_GUARD_NOS_TYPE_VERSION"), 2)
5055+
50425056

50435057
def global_identity(x):
50445058
return x

0 commit comments

Comments
 (0)