mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-43683: Streamline YIELD_VALUE and SEND (GH-30723)
* Split YIELD_VALUE into ASYNC_GEN_WRAP; YIELD_VALUE for async generators. * Split SEND into SEND; YIELD_VALUE. * Document new opcodes.
This commit is contained in:
parent
d75a51bea3
commit
0367a36fdc
9 changed files with 72 additions and 43 deletions
|
@ -2650,32 +2650,25 @@ handle_eval_breaker:
|
|||
}
|
||||
assert (gen_status == PYGEN_NEXT);
|
||||
assert (retval != NULL);
|
||||
frame->f_state = FRAME_SUSPENDED;
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
TRACE_FUNCTION_EXIT();
|
||||
DTRACE_FUNCTION_EXIT();
|
||||
_Py_LeaveRecursiveCall(tstate);
|
||||
/* Restore previous cframe and return. */
|
||||
tstate->cframe = cframe.previous;
|
||||
tstate->cframe->use_tracing = cframe.use_tracing;
|
||||
assert(tstate->cframe->current_frame == frame->previous);
|
||||
assert(!_PyErr_Occurred(tstate));
|
||||
return retval;
|
||||
PUSH(retval);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(ASYNC_GEN_WRAP) {
|
||||
PyObject *v = TOP();
|
||||
assert(frame->f_code->co_flags & CO_ASYNC_GENERATOR);
|
||||
PyObject *w = _PyAsyncGenValueWrapperNew(v);
|
||||
if (w == NULL) {
|
||||
goto error;
|
||||
}
|
||||
SET_TOP(w);
|
||||
Py_DECREF(v);
|
||||
DISPATCH();
|
||||
}
|
||||
|
||||
TARGET(YIELD_VALUE) {
|
||||
assert(frame->is_entry);
|
||||
PyObject *retval = POP();
|
||||
|
||||
if (frame->f_code->co_flags & CO_ASYNC_GENERATOR) {
|
||||
PyObject *w = _PyAsyncGenValueWrapperNew(retval);
|
||||
Py_DECREF(retval);
|
||||
if (w == NULL) {
|
||||
retval = NULL;
|
||||
goto error;
|
||||
}
|
||||
retval = w;
|
||||
}
|
||||
frame->f_state = FRAME_SUSPENDED;
|
||||
_PyFrame_SetStackPointer(frame, stack_pointer);
|
||||
TRACE_FUNCTION_EXIT();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue