Skip to content

Commit af09d44

Browse files
fix test_opt
1 parent 5032630 commit af09d44

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1464,14 +1464,14 @@ class Bar:
14641464
pass
14651465

14661466
res, ex = self._run_with_optimizer(thing, Foo())
1467-
opnames = list(iter_opnames(ex))
1468-
self.assertIsNotNone(ex)
1469-
self.assertEqual(res, TIER2_THRESHOLD * 6 + 1)
1470-
call = opnames.index("_CALL_BUILTIN_FAST")
1471-
load_attr_top = opnames.index("_POP_TOP_LOAD_CONST_INLINE_BORROW", 0, call)
1472-
load_attr_bottom = opnames.index("_POP_TOP_LOAD_CONST_INLINE_BORROW", call)
1473-
self.assertEqual(opnames[:load_attr_top].count("_GUARD_TYPE_VERSION"), 1)
1474-
self.assertEqual(opnames[call:load_attr_bottom].count("_CHECK_VALIDITY"), 2)
1467+
if ex is not None:
1468+
opnames = list(iter_opnames(ex))
1469+
self.assertEqual(res, TIER2_THRESHOLD * 6 + 1)
1470+
call = opnames.index("_CALL_BUILTIN_FAST")
1471+
load_attr_top = opnames.index("_POP_TOP_LOAD_CONST_INLINE_BORROW", 0, call)
1472+
load_attr_bottom = opnames.index("_POP_TOP_LOAD_CONST_INLINE_BORROW", call)
1473+
self.assertEqual(opnames[:load_attr_top].count("_GUARD_TYPE_VERSION"), 1)
1474+
self.assertEqual(opnames[call:load_attr_bottom].count("_CHECK_VALIDITY"), 2)
14751475

14761476
def test_guard_type_version_removed_escaping(self):
14771477

Modules/_testinternalcapi.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3023,7 +3023,7 @@ module_exec(PyObject *module)
30233023
return 1;
30243024
}
30253025

3026-
long resume_threshold = interp->opt_config.resume_initial_value + 1;
3026+
long resume_threshold = interp->opt_config.resume_initial_value + 2;
30273027
if (PyModule_Add(module, "TIER2_RESUME_THRESHOLD",
30283028
// + 1 more due to one loop spent on tracing.
30293029
PyLong_FromLong(resume_threshold)) < 0) {

0 commit comments

Comments
 (0)