Skip to content

Commit 0b806b9

Browse files
CPython Developersyouknowone
authored andcommitted
Update opcode from v3.14.2
1 parent 8c73f3c commit 0b806b9

3 files changed

Lines changed: 24 additions & 18 deletions

File tree

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_opcodes.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,23 +36,22 @@ def test_default_annotations_exist(self):
3636
class C: pass
3737
self.assertEqual(C.__annotations__, {})
3838

39-
# TODO: RustPython - test expectation changed in 3.14 due to PEP 649
40-
@unittest.expectedFailure
4139
def test_use_existing_annotations(self):
4240
ns = {'__annotations__': {1: 2}}
4341
exec('x: int', ns)
44-
self.assertEqual(ns['__annotations__'], {'x': int, 1: 2})
42+
self.assertEqual(ns['__annotations__'], {1: 2})
4543

46-
# TODO: RustPython - test expectation changed in 3.14 due to PEP 649
47-
@unittest.expectedFailure
4844
def test_do_not_recreate_annotations(self):
4945
# Don't rely on the existence of the '__annotations__' global.
5046
with support.swap_item(globals(), '__annotations__', {}):
51-
del globals()['__annotations__']
47+
globals().pop('__annotations__', None)
5248
class C:
53-
del __annotations__
54-
with self.assertRaises(NameError):
55-
x: int
49+
try:
50+
del __annotations__
51+
except NameError:
52+
pass
53+
x: int
54+
self.assertEqual(C.__annotations__, {"x": int})
5655

5756
def test_raise_class_exceptions(self):
5857

0 commit comments

Comments
 (0)