This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author BTaskaya
Recipients BTaskaya, aeros, asvetlov, carltongibson, chris.jerdonek, eamanu, felixxm, yselivanov
Date 2020-05-20.15:06:56
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1589987216.36.0.97335916354.issue40696@roundup.psfhosted.org>
In-reply-to
Content
> Is this a separate bug? So maybe the issue is that the new code is letting things get into this state. Some of my changes added new chaining in various places, so that would fit (but still investigating).

Looks like there isn't a recursion guard on https://github.com/python/cpython/blob/e572c7f6dbe5397153803eab256e4a4ca3384f80/Python/errors.c#L143-L154

I'm not sure if this would be the real solution but, for this case, it works 
diff --git a/Python/errors.c b/Python/errors.c
index 3b42c1120b..ba3df483e2 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -141,8 +141,8 @@ _PyErr_SetObject(PyThreadState *tstate, PyObject *exception, PyObject *value)
            usually very short. Sensitive readers may try
            to inline the call to PyException_GetContext. */
         if (exc_value != value) {
-            PyObject *o = exc_value, *context;
-            while ((context = PyException_GetContext(o))) {
+            PyObject *o = exc_value, *context = NULL;
+            while (o != context && (context = PyException_GetContext(o))) {
                 Py_DECREF(context);
                 if (context == value) {
                     PyException_SetContext(o, NULL);
(END)
History
Date User Action Args
2020-05-20 15:06:56BTaskayasetrecipients: + BTaskaya, asvetlov, chris.jerdonek, yselivanov, eamanu, aeros, carltongibson, felixxm
2020-05-20 15:06:56BTaskayasetmessageid: <1589987216.36.0.97335916354.issue40696@roundup.psfhosted.org>
2020-05-20 15:06:56BTaskayalinkissue40696 messages
2020-05-20 15:06:56BTaskayacreate