Skip to content

Commit faa2604

Browse files
gh-134584: Fix _CALL_BUILTIN_O test to reflect real-world usage (GH-143333)
Fix test to reflect real-world usage
1 parent d00d39f commit faa2604

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

Lib/test/test_capi/test_opt.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2201,18 +2201,18 @@ def test_call_builtin_o(self):
22012201
def testfunc(n):
22022202
x = 0
22032203
for _ in range(n):
2204-
my_abs = abs
2205-
y = my_abs(1)
2204+
y = abs(1)
22062205
x += y
22072206
return x
22082207

22092208
res, ex = self._run_with_optimizer(testfunc, TIER2_THRESHOLD)
22102209
self.assertEqual(res, TIER2_THRESHOLD)
22112210
self.assertIsNotNone(ex)
22122211
uops = get_opnames(ex)
2212+
pop_tops = [opname for opname in iter_opnames(ex) if opname == "_POP_TOP"]
22132213
self.assertIn("_CALL_BUILTIN_O", uops)
2214-
self.assertNotIn("_POP_TOP", uops)
22152214
self.assertIn("_POP_TOP_NOP", uops)
2215+
self.assertLessEqual(len(pop_tops), 1)
22162216

22172217
def test_call_method_descriptor_o(self):
22182218
def testfunc(n):

0 commit comments

Comments
 (0)