From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Tue, 19 May 2020 02:14:13 +0000 (-0700) Subject: Use _PyErr_ChainStackItem() inside gen_send_ex(). (GH-20173) (#20202) X-Git-Tag: v3.9.0b2~138 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=f02c3048dc2f22053a2ba56ef5987967b89c4be3;p=thirdparty%2FPython%2Fcpython.git 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 ff7a8b03c49153021d6de5d0b2fa8b5163059ed6) Co-authored-by: Chris Jerdonek Co-authored-by: Chris Jerdonek --- diff --git a/Objects/genobject.c b/Objects/genobject.c index 40179cdbf7db..271720bdf8b4 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -203,16 +203,8 @@ gen_send_ex(PyGenObject *gen, PyObject *arg, int exc, int closing) assert(f->f_back == NULL); f->f_back = tstate->frame; - _PyErr_StackItem *gi_exc_state = &gen->gi_exc_state; - if (exc && gi_exc_state->exc_type != NULL && - gi_exc_state->exc_type != Py_None) - { - Py_INCREF(gi_exc_state->exc_type); - Py_XINCREF(gi_exc_state->exc_value); - Py_XINCREF(gi_exc_state->exc_traceback); - _PyErr_ChainExceptions(gi_exc_state->exc_type, - gi_exc_state->exc_value, - gi_exc_state->exc_traceback); + if (exc) { + _PyErr_ChainStackItem(&gen->gi_exc_state); } gen->gi_running = 1;