Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
update test
  • Loading branch information
iritkatriel committed Feb 5, 2025
commit a5af6dad3ed4834e53ce3546c78bb35ce9daf9e8
7 changes: 5 additions & 2 deletions Lib/test/test_peepholer.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import dis
from itertools import combinations, product
import opcode
import sys
import textwrap
import unittest
Expand Down Expand Up @@ -517,13 +518,15 @@ def test_folding_subscript(self):
('("a" * 10)[10]', True),
('(1, (1, 2))[2:6][0][2-1]', True),
]
subscr_argval = 26
assert opcode._nb_ops[subscr_argval][0] == 'NB_SUBSCR'
for expr, has_error in tests:
with self.subTest(expr=expr, has_error=has_error):
code = compile(expr, '', 'single')
if not has_error:
self.assertNotInBytecode(code, 'BINARY_SUBSCR')
self.assertNotInBytecode(code, 'BINARY_OP', argval=subscr_argval)
else:
self.assertInBytecode(code, 'BINARY_SUBSCR')
self.assertInBytecode(code, 'BINARY_OP', argval=subscr_argval)
self.check_lnotab(code)

def test_in_literal_list(self):
Expand Down