Skip to content

Commit 7742eca

Browse files
CPython Developersyouknowone
authored andcommitted
Update opcode from CPython 3.10.6
1 parent 81a53a1 commit 7742eca

File tree

2 files changed

+36
-36
lines changed

2 files changed

+36
-36
lines changed

Lib/opcode.py

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
except ImportError:
2222
pass
2323

24-
cmp_op = ('<', '<=', '==', '!=', '>', '>=', 'in', 'not in', 'is',
25-
'is not', 'exception match', 'BAD')
24+
cmp_op = ('<', '<=', '==', '!=', '>', '>=')
2625

2726
hasconst = []
2827
hasname = []
@@ -60,14 +59,14 @@ def jabs_op(name, op):
6059
def_op('ROT_THREE', 3)
6160
def_op('DUP_TOP', 4)
6261
def_op('DUP_TOP_TWO', 5)
62+
def_op('ROT_FOUR', 6)
6363

6464
def_op('NOP', 9)
6565
def_op('UNARY_POSITIVE', 10)
6666
def_op('UNARY_NEGATIVE', 11)
6767
def_op('UNARY_NOT', 12)
6868

6969
def_op('UNARY_INVERT', 15)
70-
7170
def_op('BINARY_MATRIX_MULTIPLY', 16)
7271
def_op('INPLACE_MATRIX_MULTIPLY', 17)
7372

@@ -82,11 +81,18 @@ def jabs_op(name, op):
8281
def_op('BINARY_TRUE_DIVIDE', 27)
8382
def_op('INPLACE_FLOOR_DIVIDE', 28)
8483
def_op('INPLACE_TRUE_DIVIDE', 29)
84+
def_op('GET_LEN', 30)
85+
def_op('MATCH_MAPPING', 31)
86+
def_op('MATCH_SEQUENCE', 32)
87+
def_op('MATCH_KEYS', 33)
88+
def_op('COPY_DICT_WITHOUT_KEYS', 34)
8589

90+
def_op('WITH_EXCEPT_START', 49)
8691
def_op('GET_AITER', 50)
8792
def_op('GET_ANEXT', 51)
8893
def_op('BEFORE_ASYNC_WITH', 52)
8994

95+
def_op('END_ASYNC_FOR', 54)
9096
def_op('INPLACE_ADD', 55)
9197
def_op('INPLACE_SUBTRACT', 56)
9298
def_op('INPLACE_MULTIPLY', 57)
@@ -102,27 +108,24 @@ def jabs_op(name, op):
102108
def_op('INPLACE_POWER', 67)
103109
def_op('GET_ITER', 68)
104110
def_op('GET_YIELD_FROM_ITER', 69)
105-
106111
def_op('PRINT_EXPR', 70)
107112
def_op('LOAD_BUILD_CLASS', 71)
108113
def_op('YIELD_FROM', 72)
109114
def_op('GET_AWAITABLE', 73)
110-
115+
def_op('LOAD_ASSERTION_ERROR', 74)
111116
def_op('INPLACE_LSHIFT', 75)
112117
def_op('INPLACE_RSHIFT', 76)
113118
def_op('INPLACE_AND', 77)
114119
def_op('INPLACE_XOR', 78)
115120
def_op('INPLACE_OR', 79)
116-
def_op('BREAK_LOOP', 80)
117-
def_op('WITH_CLEANUP_START', 81)
118-
def_op('WITH_CLEANUP_FINISH', 82)
119121

122+
def_op('LIST_TO_TUPLE', 82)
120123
def_op('RETURN_VALUE', 83)
121124
def_op('IMPORT_STAR', 84)
122125
def_op('SETUP_ANNOTATIONS', 85)
123126
def_op('YIELD_VALUE', 86)
124127
def_op('POP_BLOCK', 87)
125-
def_op('END_FINALLY', 88)
128+
126129
def_op('POP_EXCEPT', 89)
127130

128131
HAVE_ARGUMENT = 90 # Opcodes from here have an argument:
@@ -136,45 +139,46 @@ def jabs_op(name, op):
136139
name_op('DELETE_ATTR', 96) # ""
137140
name_op('STORE_GLOBAL', 97) # ""
138141
name_op('DELETE_GLOBAL', 98) # ""
142+
def_op('ROT_N', 99)
139143
def_op('LOAD_CONST', 100) # Index in const list
140144
hasconst.append(100)
141145
name_op('LOAD_NAME', 101) # Index in name list
142146
def_op('BUILD_TUPLE', 102) # Number of tuple items
143147
def_op('BUILD_LIST', 103) # Number of list items
144148
def_op('BUILD_SET', 104) # Number of set items
145-
def_op('BUILD_MAP', 105) # Number of dict entries (upto 255)
149+
def_op('BUILD_MAP', 105) # Number of dict entries
146150
name_op('LOAD_ATTR', 106) # Index in name list
147151
def_op('COMPARE_OP', 107) # Comparison operator
148152
hascompare.append(107)
149153
name_op('IMPORT_NAME', 108) # Index in name list
150154
name_op('IMPORT_FROM', 109) # Index in name list
151-
152155
jrel_op('JUMP_FORWARD', 110) # Number of bytes to skip
153156
jabs_op('JUMP_IF_FALSE_OR_POP', 111) # Target byte offset from beginning of code
154157
jabs_op('JUMP_IF_TRUE_OR_POP', 112) # ""
155158
jabs_op('JUMP_ABSOLUTE', 113) # ""
156159
jabs_op('POP_JUMP_IF_FALSE', 114) # ""
157160
jabs_op('POP_JUMP_IF_TRUE', 115) # ""
158-
159161
name_op('LOAD_GLOBAL', 116) # Index in name list
162+
def_op('IS_OP', 117)
163+
def_op('CONTAINS_OP', 118)
164+
def_op('RERAISE', 119)
160165

161-
jabs_op('CONTINUE_LOOP', 119) # Target address
162-
jrel_op('SETUP_LOOP', 120) # Distance to target address
163-
jrel_op('SETUP_EXCEPT', 121) # ""
164-
jrel_op('SETUP_FINALLY', 122) # ""
166+
jabs_op('JUMP_IF_NOT_EXC_MATCH', 121)
167+
jrel_op('SETUP_FINALLY', 122) # Distance to target address
165168

166169
def_op('LOAD_FAST', 124) # Local variable number
167170
haslocal.append(124)
168171
def_op('STORE_FAST', 125) # Local variable number
169172
haslocal.append(125)
170173
def_op('DELETE_FAST', 126) # Local variable number
171174
haslocal.append(126)
172-
name_op('STORE_ANNOTATION', 127) # Index in name list
173175

176+
def_op('GEN_START', 129) # Kind of generator/coroutine
174177
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
175178
def_op('CALL_FUNCTION', 131) # #args
176179
def_op('MAKE_FUNCTION', 132) # Flags
177180
def_op('BUILD_SLICE', 133) # Number of items
181+
178182
def_op('LOAD_CLOSURE', 135)
179183
hasfree.append(135)
180184
def_op('LOAD_DEREF', 136)
@@ -186,30 +190,27 @@ def jabs_op(name, op):
186190

187191
def_op('CALL_FUNCTION_KW', 141) # #args + #kwargs
188192
def_op('CALL_FUNCTION_EX', 142) # Flags
189-
190193
jrel_op('SETUP_WITH', 143)
191-
194+
def_op('EXTENDED_ARG', 144)
195+
EXTENDED_ARG = 144
192196
def_op('LIST_APPEND', 145)
193197
def_op('SET_ADD', 146)
194198
def_op('MAP_ADD', 147)
195-
196199
def_op('LOAD_CLASSDEREF', 148)
197200
hasfree.append(148)
198201

199-
def_op('EXTENDED_ARG', 144)
200-
EXTENDED_ARG = 144
201-
202-
def_op('BUILD_LIST_UNPACK', 149)
203-
def_op('BUILD_MAP_UNPACK', 150)
204-
def_op('BUILD_MAP_UNPACK_WITH_CALL', 151)
205-
def_op('BUILD_TUPLE_UNPACK', 152)
206-
def_op('BUILD_SET_UNPACK', 153)
202+
def_op('MATCH_CLASS', 152)
207203

208204
jrel_op('SETUP_ASYNC_WITH', 154)
209-
210205
def_op('FORMAT_VALUE', 155)
211206
def_op('BUILD_CONST_KEY_MAP', 156)
212207
def_op('BUILD_STRING', 157)
213-
def_op('BUILD_TUPLE_UNPACK_WITH_CALL', 158)
208+
209+
name_op('LOAD_METHOD', 160)
210+
def_op('CALL_METHOD', 161)
211+
def_op('LIST_EXTEND', 162)
212+
def_op('SET_UPDATE', 163)
213+
def_op('DICT_MERGE', 164)
214+
def_op('DICT_UPDATE', 165)
214215

215216
del def_op, name_op, jrel_op, jabs_op

Lib/test/test_opcodes.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Python test set -- part 2, opcodes
22

33
import unittest
4-
from test import support #,ann_module
4+
from test import ann_module, support
55

66
class OpcodeTest(unittest.TestCase):
77

@@ -26,17 +26,16 @@ def test_try_inside_for_loop(self):
2626
def test_setup_annotations_line(self):
2727
# check that SETUP_ANNOTATIONS does not create spurious line numbers
2828
try:
29-
with open(ann_module.__file__) as f:
29+
with open(ann_module.__file__, encoding="utf-8") as f:
3030
txt = f.read()
3131
co = compile(txt, ann_module.__file__, 'exec')
32-
self.assertEqual(co.co_firstlineno, 3)
32+
self.assertEqual(co.co_firstlineno, 1)
3333
except OSError:
3434
pass
3535

36-
def test_no_annotations_if_not_needed(self):
36+
def test_default_annotations_exist(self):
3737
class C: pass
38-
with self.assertRaises(AttributeError):
39-
C.__annotations__
38+
self.assertEqual(C.__annotations__, {})
4039

4140
def test_use_existing_annotations(self):
4241
ns = {'__annotations__': {1: 2}}

0 commit comments

Comments
 (0)