[3.9] bpo-40696: Fix a hang that can arise after gen.throw() (GH-20287) by miss-islington · Pull Request #20321 · python/cpython
This updates _PyErr_ChainStackItem() to use _PyErr_SetObject()
instead of _PyErr_ChainExceptions(). This prevents a hang in
certain circumstances because _PyErr_SetObject() performs checks
to prevent cycles in the exception context chain while
_PyErr_ChainExceptions() doesn't.
(cherry picked from commit 7c30d12)
Co-authored-by: Chris Jerdonek chris.jerdonek@gmail.com