mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
GH-96793: Specialize FOR_ITER for generators. (GH-98772)
This commit is contained in:
parent
80c08d1cd6
commit
4a1c58d504
13 changed files with 207 additions and 71 deletions
|
@ -209,7 +209,8 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
|
|||
|
||||
frame->previous = tstate->cframe->current_frame;
|
||||
|
||||
gen->gi_exc_state.previous_item = tstate->exc_info;
|
||||
_PyErr_StackItem *prev_exc_info = tstate->exc_info;
|
||||
gen->gi_exc_state.previous_item = prev_exc_info;
|
||||
tstate->exc_info = &gen->gi_exc_state;
|
||||
|
||||
if (exc) {
|
||||
|
@ -220,12 +221,11 @@ gen_send_ex2(PyGenObject *gen, PyObject *arg, PyObject **presult,
|
|||
gen->gi_frame_state = FRAME_EXECUTING;
|
||||
EVAL_CALL_STAT_INC(EVAL_CALL_GENERATOR);
|
||||
result = _PyEval_EvalFrame(tstate, frame, exc);
|
||||
assert(tstate->exc_info == prev_exc_info);
|
||||
assert(gen->gi_exc_state.previous_item == NULL);
|
||||
if (gen->gi_frame_state == FRAME_EXECUTING) {
|
||||
gen->gi_frame_state = FRAME_COMPLETED;
|
||||
}
|
||||
tstate->exc_info = gen->gi_exc_state.previous_item;
|
||||
gen->gi_exc_state.previous_item = NULL;
|
||||
|
||||
assert(tstate->cframe->current_frame == frame->previous);
|
||||
/* Don't keep the reference to previous any longer than necessary. It
|
||||
* may keep a chain of frames alive or it could create a reference
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue