Skip to content

Commit 9bfa922

Browse files
committed
Generators
1 parent 90bf8df commit 9bfa922

File tree

3 files changed

+22
-19
lines changed

3 files changed

+22
-19
lines changed

Python/bytecodes.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1201,14 +1201,16 @@ dummy_func(
12011201

12021202
PyObject *retval_o;
12031203
assert(frame->owner != FRAME_OWNED_BY_INTERPRETER);
1204+
_PyStackRef tmp = _PyStackRef_StealIfUnborrowed(v);
1205+
DEAD(v);
12041206
if ((tstate->interp->eval_frame == NULL) &&
12051207
(Py_TYPE(receiver_o) == &PyGen_Type || Py_TYPE(receiver_o) == &PyCoro_Type) &&
12061208
((PyGenObject *)receiver_o)->gi_frame_state < FRAME_EXECUTING)
12071209
{
12081210
PyGenObject *gen = (PyGenObject *)receiver_o;
12091211
_PyInterpreterFrame *gen_frame = &gen->gi_iframe;
12101212
STACK_SHRINK(1);
1211-
_PyFrame_StackPush(gen_frame, v);
1213+
_PyFrame_StackPush(gen_frame, tmp);
12121214
gen->gi_frame_state = FRAME_EXECUTING;
12131215
gen->gi_exc_state.previous_item = tstate->exc_info;
12141216
tstate->exc_info = &gen->gi_exc_state;
@@ -1224,7 +1226,7 @@ dummy_func(
12241226
else {
12251227
retval_o = PyObject_CallMethodOneArg(receiver_o,
12261228
&_Py_ID(send),
1227-
PyStackRef_AsPyObjectBorrow(v));
1229+
PyStackRef_AsPyObjectBorrow(tmp));
12281230
}
12291231
if (retval_o == NULL) {
12301232
int matches = _PyErr_ExceptionMatches(tstate, PyExc_StopIteration);
@@ -1237,11 +1239,11 @@ dummy_func(
12371239
JUMPBY(oparg);
12381240
}
12391241
else {
1240-
PyStackRef_CLOSE(v);
1242+
PyStackRef_CLOSE(tmp);
12411243
ERROR_IF(true, error);
12421244
}
12431245
}
1244-
PyStackRef_CLOSE(v);
1246+
PyStackRef_CLOSE(tmp);
12451247
retval = PyStackRef_FromPyObjectSteal(retval_o);
12461248
}
12471249

@@ -1253,7 +1255,7 @@ dummy_func(
12531255
DEOPT_IF(gen->gi_frame_state >= FRAME_EXECUTING);
12541256
STAT_INC(SEND, hit);
12551257
gen_frame = &gen->gi_iframe;
1256-
_PyFrame_StackPush(gen_frame, v);
1258+
_PyFrame_StackPush(gen_frame, _PyStackRef_StealIfUnborrowed(v));
12571259
DEAD(v);
12581260
gen->gi_frame_state = FRAME_EXECUTING;
12591261
gen->gi_exc_state.previous_item = tstate->exc_info;
@@ -1300,7 +1302,7 @@ dummy_func(
13001302
#endif
13011303
RELOAD_STACK();
13021304
LOAD_IP(1 + INLINE_CACHE_ENTRIES_SEND);
1303-
value = temp;
1305+
value = _PyStackRef_StealIfUnborrowed(temp);
13041306
LLTRACE_RESUME_FRAME();
13051307
}
13061308

Python/executor_cases.c.h

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Python/generated_cases.c.h

Lines changed: 12 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)