Skip to content

Commit f02c304

Browse files
Use _PyErr_ChainStackItem() inside gen_send_ex(). (GH-20173) (#20202)
_PyErr_ChainStackItem was just added in GH-19951 (for bpo-31033). (cherry picked from commit ff7a8b0) Co-authored-by: Chris Jerdonek <[email protected]> Co-authored-by: Chris Jerdonek <[email protected]>
1 parent 1bf7578 commit f02c304

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

Objects/genobject.c

+2-10
Original file line numberDiff line numberDiff line change
@@ -203,16 +203,8 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing)
203203
assert(f->f_back == NULL);
204204
f->f_back = tstate->frame;
205205

206-
_PyErr_StackItem *gi_exc_state = &gen->gi_exc_state;
207-
if (exc && gi_exc_state->exc_type != NULL &&
208-
gi_exc_state->exc_type != Py_None)
209-
{
210-
Py_INCREF(gi_exc_state->exc_type);
211-
Py_XINCREF(gi_exc_state->exc_value);
212-
Py_XINCREF(gi_exc_state->exc_traceback);
213-
_PyErr_ChainExceptions(gi_exc_state->exc_type,
214-
gi_exc_state->exc_value,
215-
gi_exc_state->exc_traceback);
206+
if (exc) {
207+
_PyErr_ChainStackItem(&gen->gi_exc_state);
216208
}
217209

218210
gen->gi_running = 1;

0 commit comments

Comments
 (0)