Previously, this instruction also pushed a boolean value indicating
success (``True``) or failure (``False``).
-.. opcode:: GEN_START (kind)
-
- Pops TOS. The ``kind`` operand corresponds to the type of generator or
- coroutine. The legal kinds are 0 for generator, 1 for coroutine,
- and 2 for async generator.
-
- .. versionadded:: 3.10
-
.. opcode:: ROT_N (count)
This decouples the argument shifting for methods from the handling of
keyword arguments and allows better specialization of calls.
-* Removed ``COPY_DICT_WITHOUT_KEYS``.
+* Removed ``COPY_DICT_WITHOUT_KEYS`` and ``GEN_START``.
* :opcode:`MATCH_CLASS` and :opcode:`MATCH_KEYS` no longer push an additional
boolean value indicating whether the match succeeded or failed. Instead, they
#define STORE_FAST 125
#define DELETE_FAST 126
#define JUMP_IF_NOT_EG_MATCH 127
-#define GEN_START 129
#define RAISE_VARARGS 130
#define MAKE_FUNCTION 132
#define BUILD_SLICE 133
#define STORE_ATTR_WITH_HINT 81
#define LOAD_FAST__LOAD_FAST 87
#define STORE_FAST__LOAD_FAST 128
-#define LOAD_FAST__LOAD_CONST 131
-#define LOAD_CONST__LOAD_FAST 134
-#define STORE_FAST__STORE_FAST 140
+#define LOAD_FAST__LOAD_CONST 129
+#define LOAD_CONST__LOAD_FAST 131
+#define STORE_FAST__STORE_FAST 134
#define DO_TRACING 255
#ifdef NEED_OPCODE_JUMP_TABLES
static uint32_t _PyOpcode_RelativeJump[8] = {
# Python 3.11a4 3469 (bpo-45711: remove type, traceback from exc_info)
# Python 3.11a4 3470 (bpo-46221: PREP_RERAISE_STAR no longer pushes lasti)
# Python 3.11a4 3471 (bpo-46202: remove pop POP_EXCEPT_AND_RERAISE)
+# Python 3.11a4 3472 (bpo-46009: replace GEN_START with POP_TOP)
#
# MAGIC must change whenever the bytecode emitted by the compiler may no
# Whenever MAGIC_NUMBER is changed, the ranges in the magic_values array
# in PC/launcher.c must also be updated.
-MAGIC_NUMBER = (3471).to_bytes(2, 'little') + b'\r\n'
+MAGIC_NUMBER = (3472).to_bytes(2, 'little') + b'\r\n'
_RAW_MAGIC_NUMBER = int.from_bytes(MAGIC_NUMBER, 'little') # For import.c
_PYCACHE = '__pycache__'
jabs_op('JUMP_IF_NOT_EG_MATCH', 127)
-def_op('GEN_START', 129) # Kind of generator/coroutine
def_op('RAISE_VARARGS', 130) # Number of raise arguments (1, 2, or 3)
def_op('MAKE_FUNCTION', 132) # Flags
--- /dev/null
+Remove the ``GEN_START`` opcode.
stacks[i] = UNINITIALIZED;
}
stacks[0] = 0;
+ if (code_obj->co_flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR))
+ {
+ // Generators get sent None while starting:
+ stacks[0] = push_value(stacks[0], Object);
+ }
int todo = 1;
while (todo) {
todo = 0;
case RERAISE:
/* End of block */
break;
- case GEN_START:
- stacks[i+1] = next_stack;
- break;
default:
{
int delta = PyCompile_OpcodeStackEffect(opcode, _Py_OPARG(code[i]));
return retval;
}
- TARGET(GEN_START) {
- PyObject *none = POP();
- assert(none == Py_None);
- assert(oparg < 3);
- Py_DECREF(none);
- DISPATCH();
- }
-
TARGET(POP_EXCEPT) {
_PyErr_StackItem *exc_info = tstate->exc_info;
PyObject *value = exc_info->exc_value;
return 1;
case LIST_TO_TUPLE:
return 0;
- case GEN_START:
- return -1;
case LIST_EXTEND:
case SET_UPDATE:
case DICT_MERGE:
/* Add the generator prefix instructions. */
if (flags & (CO_GENERATOR | CO_COROUTINE | CO_ASYNC_GENERATOR)) {
- int kind;
- if (flags & CO_COROUTINE) {
- kind = 1;
- }
- else if (flags & CO_ASYNC_GENERATOR) {
- kind = 2;
- }
- else {
- kind = 0;
- }
-
- struct instr gen_start = {
- .i_opcode = GEN_START,
- .i_oparg = kind,
+ struct instr pop_top = {
+ .i_opcode = POP_TOP,
+ .i_oparg = 0,
.i_lineno = -1,
.i_col_offset = -1,
.i_end_lineno = -1,
.i_end_col_offset = -1,
.i_target = NULL,
};
- if (insert_instruction(entryblock, 0, &gen_start) < 0) {
+ if (insert_instruction(entryblock, 0, &pop_top) < 0) {
return -1;
}
}
&&TARGET_DELETE_FAST,
&&TARGET_JUMP_IF_NOT_EG_MATCH,
&&TARGET_STORE_FAST__LOAD_FAST,
- &&TARGET_GEN_START,
- &&TARGET_RAISE_VARARGS,
&&TARGET_LOAD_FAST__LOAD_CONST,
+ &&TARGET_RAISE_VARARGS,
+ &&TARGET_LOAD_CONST__LOAD_FAST,
&&TARGET_MAKE_FUNCTION,
&&TARGET_BUILD_SLICE,
- &&TARGET_LOAD_CONST__LOAD_FAST,
+ &&TARGET_STORE_FAST__STORE_FAST,
&&TARGET_MAKE_CELL,
&&TARGET_LOAD_CLOSURE,
&&TARGET_LOAD_DEREF,
&&TARGET_STORE_DEREF,
&&TARGET_DELETE_DEREF,
- &&TARGET_STORE_FAST__STORE_FAST,
+ &&_unknown_opcode,
&&_unknown_opcode,
&&TARGET_CALL_FUNCTION_EX,
&&_unknown_opcode,