Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 0 additions & 8 deletions Doc/library/dis.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1175,14 +1175,6 @@ All of the following opcodes use their arguments.
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)

Expand Down
2 changes: 1 addition & 1 deletion Doc/whatsnew/3.11.rst
Original file line number Diff line number Diff line change
Expand Up @@ -388,7 +388,7 @@ CPython bytecode changes
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
Expand Down
7 changes: 3 additions & 4 deletions Include/opcode.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion Lib/importlib/_bootstrap_external.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,7 @@ def _write_atomic(path, data, mode=0o666):
# 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
Expand All @@ -386,7 +387,7 @@ def _write_atomic(path, data, mode=0o666):
# 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__'
Expand Down
1 change: 0 additions & 1 deletion Lib/opcode.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,6 @@ def jabs_op(name, op):

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
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Remove the ``GEN_START`` opcode.
8 changes: 5 additions & 3 deletions Objects/frameobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,11 @@ mark_stacks(PyCodeObject *code_obj, int len)
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;
Expand Down Expand Up @@ -291,9 +296,6 @@ mark_stacks(PyCodeObject *code_obj, int len)
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]));
Expand Down
8 changes: 0 additions & 8 deletions Python/ceval.c
Original file line number Diff line number Diff line change
Expand Up @@ -2709,14 +2709,6 @@ _PyEval_EvalFrameDefault(PyThreadState *tstate, InterpreterFrame *frame, int thr
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;
Expand Down
21 changes: 4 additions & 17 deletions Python/compile.c
Original file line number Diff line number Diff line change
Expand Up @@ -1208,8 +1208,6 @@ stack_effect(int opcode, int oparg, int jump)
return 1;
case LIST_TO_TUPLE:
return 0;
case GEN_START:
return -1;
case LIST_EXTEND:
case SET_UPDATE:
case DICT_MERGE:
Expand Down Expand Up @@ -8028,27 +8026,16 @@ insert_prefix_instructions(struct compiler *c, basicblock *entryblock,

/* 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;
}
}
Expand Down
8 changes: 4 additions & 4 deletions Python/opcode_targets.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.