Skip to content

Commit 93b26bf

Browse files
authored
Merge pull request #6869 from youknowone/opcode
Update opcode, dis from 3.14.2
2 parents 617cdc9 + 4b823eb commit 93b26bf

14 files changed

+1161
-622
lines changed

Lib/dis.py

Lines changed: 131 additions & 48 deletions
Large diffs are not rendered by default.

Lib/opcode.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,18 @@
99
"HAVE_ARGUMENT", "EXTENDED_ARG", "hasarg", "hasconst", "hasname",
1010
"hasjump", "hasjrel", "hasjabs", "hasfree", "haslocal", "hasexc"]
1111

12+
import builtins
1213
import _opcode
1314
from _opcode import stack_effect
1415

15-
from _opcode_metadata import (_specializations, _specialized_opmap, opmap,
16-
HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE)
16+
from _opcode_metadata import (_specializations, _specialized_opmap, opmap, # noqa: F401
17+
HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE) # noqa: F401
1718
EXTENDED_ARG = opmap['EXTENDED_ARG']
1819

1920
opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)]
20-
for op, i in opmap.items():
21-
opname[i] = op
21+
for m in (opmap, _specialized_opmap):
22+
for op, i in m.items():
23+
opname[i] = op
2224

2325
cmp_op = ('<', '<=', '==', '!=', '>', '>=')
2426

@@ -36,6 +38,9 @@
3638

3739
_intrinsic_1_descs = _opcode.get_intrinsic1_descs()
3840
_intrinsic_2_descs = _opcode.get_intrinsic2_descs()
41+
_special_method_names = _opcode.get_special_method_names()
42+
_common_constants = [builtins.AssertionError, builtins.NotImplementedError,
43+
builtins.tuple, builtins.all, builtins.any]
3944
_nb_ops = _opcode.get_nb_ops()
4045

4146
hascompare = [opmap["COMPARE_OP"]]
@@ -49,6 +54,7 @@
4954
},
5055
"BINARY_OP": {
5156
"counter": 1,
57+
"descr": 4,
5258
},
5359
"UNPACK_SEQUENCE": {
5460
"counter": 1,
@@ -59,9 +65,6 @@
5965
"CONTAINS_OP": {
6066
"counter": 1,
6167
},
62-
"BINARY_SUBSCR": {
63-
"counter": 1,
64-
},
6568
"FOR_ITER": {
6669
"counter": 1,
6770
},
@@ -83,6 +86,10 @@
8386
"counter": 1,
8487
"func_version": 2,
8588
},
89+
"CALL_KW": {
90+
"counter": 1,
91+
"func_version": 2,
92+
},
8693
"STORE_SUBSCR": {
8794
"counter": 1,
8895
},

Lib/test/test__opcode.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_is_valid(self):
3838
opcodes = [dis.opmap[opname] for opname in names]
3939
self.check_bool_function_result(_opcode.is_valid, opcodes, True)
4040

41-
@unittest.expectedFailure # TODO: RUSTPYTHON
41+
@unittest.expectedFailure # TODO: RUSTPYTHON; KeyError: 'BINARY_OP_ADD_INT'
4242
def test_opmaps(self):
4343
def check_roundtrip(name, map):
4444
return self.assertEqual(opcode.opname[map[name]], name)
@@ -116,7 +116,7 @@ def test_stack_effect_jump(self):
116116

117117

118118
class SpecializationStatsTests(unittest.TestCase):
119-
@unittest.expectedFailure # TODO: RUSTPYTHON
119+
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: 'load_attr' not found in []
120120
def test_specialization_stats(self):
121121
stat_names = ["success", "failure", "hit", "deferred", "miss", "deopt"]
122122
specialized_opcodes = [

Lib/test/test_compile.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,8 +152,6 @@ def test_indentation(self):
152152
pass"""
153153
compile(s, "<string>", "exec")
154154

155-
# TODO: RUSTPYTHON
156-
@unittest.expectedFailure
157155
# This test is probably specific to CPython and may not generalize
158156
# to other implementations. We are trying to ensure that when
159157
# the first line of code starts after 256, correct line numbers
@@ -928,8 +926,6 @@ def save_caller_frame():
928926
func(save_caller_frame)
929927
self.assertEqual(frame.f_lineno-frame.f_code.co_firstlineno, lastline)
930928

931-
# TODO: RUSTPYTHON
932-
@unittest.expectedFailure
933929
def test_lineno_after_no_code(self):
934930
def no_code1():
935931
"doc string"

0 commit comments

Comments
 (0)