Skip to content
Merged
Show file tree
Hide file tree
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 opcode from v3.14.2
  • Loading branch information
CPython Developers authored and youknowone committed Jan 26, 2026
commit 0b806b913122e31c7935a98a6d7d1795e8176d9d
21 changes: 14 additions & 7 deletions Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,18 @@
"HAVE_ARGUMENT", "EXTENDED_ARG", "hasarg", "hasconst", "hasname",
"hasjump", "hasjrel", "hasjabs", "hasfree", "haslocal", "hasexc"]

import builtins
import _opcode
from _opcode import stack_effect

from _opcode_metadata import (_specializations, _specialized_opmap, opmap,
HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE)
from _opcode_metadata import (_specializations, _specialized_opmap, opmap, # noqa: F401
HAVE_ARGUMENT, MIN_INSTRUMENTED_OPCODE) # noqa: F401
EXTENDED_ARG = opmap['EXTENDED_ARG']

opname = ['<%r>' % (op,) for op in range(max(opmap.values()) + 1)]
for op, i in opmap.items():
opname[i] = op
for m in (opmap, _specialized_opmap):
for op, i in m.items():
opname[i] = op

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

Expand All @@ -36,6 +38,9 @@

_intrinsic_1_descs = _opcode.get_intrinsic1_descs()
_intrinsic_2_descs = _opcode.get_intrinsic2_descs()
_special_method_names = _opcode.get_special_method_names()
_common_constants = [builtins.AssertionError, builtins.NotImplementedError,
builtins.tuple, builtins.all, builtins.any]
_nb_ops = _opcode.get_nb_ops()

hascompare = [opmap["COMPARE_OP"]]
Expand All @@ -49,6 +54,7 @@
},
"BINARY_OP": {
"counter": 1,
"descr": 4,
},
"UNPACK_SEQUENCE": {
"counter": 1,
Expand All @@ -59,9 +65,6 @@
"CONTAINS_OP": {
"counter": 1,
},
"BINARY_SUBSCR": {
"counter": 1,
},
"FOR_ITER": {
"counter": 1,
},
Expand All @@ -83,6 +86,10 @@
"counter": 1,
"func_version": 2,
},
"CALL_KW": {
"counter": 1,
"func_version": 2,
},
"STORE_SUBSCR": {
"counter": 1,
},
Expand Down
4 changes: 2 additions & 2 deletions Lib/test/test__opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_is_valid(self):
opcodes = [dis.opmap[opname] for opname in names]
self.check_bool_function_result(_opcode.is_valid, opcodes, True)

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


class SpecializationStatsTests(unittest.TestCase):
@unittest.expectedFailure # TODO: RUSTPYTHON
@unittest.expectedFailure # TODO: RUSTPYTHON; AssertionError: 'load_attr' not found in []
def test_specialization_stats(self):
stat_names = ["success", "failure", "hit", "deferred", "miss", "deopt"]
specialized_opcodes = [
Expand Down
17 changes: 8 additions & 9 deletions Lib/test/test_opcodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,23 +36,22 @@ def test_default_annotations_exist(self):
class C: pass
self.assertEqual(C.__annotations__, {})

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

# TODO: RustPython - test expectation changed in 3.14 due to PEP 649
@unittest.expectedFailure
def test_do_not_recreate_annotations(self):
# Don't rely on the existence of the '__annotations__' global.
with support.swap_item(globals(), '__annotations__', {}):
del globals()['__annotations__']
globals().pop('__annotations__', None)
class C:
del __annotations__
with self.assertRaises(NameError):
x: int
try:
del __annotations__
except NameError:
pass
x: int
self.assertEqual(C.__annotations__, {"x": int})

def test_raise_class_exceptions(self):

Expand Down