Skip to content

Commit df61257

Browse files
committed
Clean up TestUops a bit
1 parent 7c59fd5 commit df61257

File tree

1 file changed

+6
-16
lines changed

1 file changed

+6
-16
lines changed

Lib/test/test_capi/test_misc.py

+6-16
Original file line numberDiff line numberDiff line change
@@ -2446,13 +2446,7 @@ def testfunc(x):
24462446
with temporary_optimizer(opt):
24472447
testfunc(1000)
24482448

2449-
ex = None
2450-
for offset in range(0, len(testfunc.__code__.co_code), 2):
2451-
try:
2452-
ex = _testinternalcapi.get_executor(testfunc.__code__, offset)
2453-
break
2454-
except ValueError:
2455-
pass
2449+
ex = get_first_executor(testfunc.__code__)
24562450
self.assertIsNotNone(ex)
24572451
uops = {opname for opname, _ in ex}
24582452
self.assertIn("SAVE_IP", uops)
@@ -2496,8 +2490,10 @@ def many_vars():
24962490
ex = get_first_executor(many_vars.__code__)
24972491
self.assertIsNone(ex)
24982492
many_vars()
2499-
ex = get_first_executor(many_vars.__code__)
2500-
self.assertIn(("LOAD_FAST", 259), list(ex))
2493+
2494+
ex = get_first_executor(many_vars.__code__)
2495+
self.assertIsNotNone(ex)
2496+
self.assertIn(("LOAD_FAST", 259), list(ex))
25012497

25022498
def test_unspecialized_unpack(self):
25032499
# An example of an unspecialized opcode
@@ -2516,13 +2512,7 @@ def testfunc(x):
25162512
with temporary_optimizer(opt):
25172513
testfunc(10)
25182514

2519-
ex = None
2520-
for offset in range(0, len(testfunc.__code__.co_code), 2):
2521-
try:
2522-
ex = _testinternalcapi.get_executor(testfunc.__code__, offset)
2523-
break
2524-
except ValueError:
2525-
pass
2515+
ex = get_first_executor(testfunc.__code__)
25262516
self.assertIsNotNone(ex)
25272517
uops = {opname for opname, _ in ex}
25282518
self.assertIn("UNPACK_SEQUENCE", uops)

0 commit comments

Comments
 (0)