diff options
author | Chris Jerdonek <chris.jerdonek@gmail.com> | 2020-04-30 19:18:05 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-30 19:18:05 (GMT) |
commit | 2514a632fb7d37be24c2059d0e286d35600f9795 (patch) | |
tree | bdf3c5f468206dae232a23b55503cf9cbced5616 /Objects | |
parent | c001c09e9059ba04bc088349cd87a1374dc0754f (diff) | |
download | cpython-2514a632fb7d37be24c2059d0e286d35600f9795.zip cpython-2514a632fb7d37be24c2059d0e286d35600f9795.tar.gz cpython-2514a632fb7d37be24c2059d0e286d35600f9795.tar.bz2 |
bpo-29587: Enable implicit exception chaining with gen.throw() (GH-19811)
Before this commit, if an exception was active inside a generator
when calling gen.throw(), then that exception was lost (i.e. there
was no implicit exception chaining). This commit fixes that.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/genobject.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/Objects/genobject.c b/Objects/genobject.c index 6e36690..289ed79 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -512,6 +512,12 @@ throw_here: } PyErr_Restore(typ, val, tb); + if (gen->gi_exc_state.exc_type) { + Py_INCREF(gen->gi_exc_state.exc_type); + Py_XINCREF(gen->gi_exc_state.exc_value); + Py_XINCREF(gen->gi_exc_state.exc_traceback); + _PyErr_ChainExceptions(gen->gi_exc_state.exc_type, gen->gi_exc_state.exc_value, gen->gi_exc_state.exc_traceback); + } return gen_send_ex(gen, Py_None, 1, 0); failed_throw: |