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 Dennis Sweeney
Recipients Dennis Sweeney, xxm
Date 2020-11-30.06:51:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1606719087.2.0.953559907215.issue42509@roundup.psfhosted.org>
In-reply-to
Content
This might be the expected behavior. See https://bugs.python.org/issue25222

If you already caught a RecursionError and you keep recursing anyway, once you go 50 levels beyond sys.getrecursionlimit(), the interpreter crashes regardless of what is `except`ed. In /Python/ceval.c, there's this:

    if (tstate->overflowed) {
        if (tstate->recursion_depth > recursion_limit + 50) {
            /* Overflowing while handling an overflow. Give up. */
            Py_FatalError("Cannot recover from stack overflow.");
        }
        return 0;
    }

In your Program 2, when the interpreter raises a `RecursionError`, it is raised normally and everything is fine.

In your Program 1, when the interpreter raises a `RecursionError`, it is `except`ed, so the interpreter thinks it's okay to keep going, and when it does, it raises more `RecursionError`s, which it keeps `except`ing, until it finally can't go any farther ( > 50 + sys.getrecursionlimit()), and has no option but to crash.

"Cannot recover from stack overflow." seems to make sense to me: when the interpreter tries to recover, the code won't let it.
History
Date User Action Args
2020-11-30 06:51:27Dennis Sweeneysetrecipients: + Dennis Sweeney, xxm
2020-11-30 06:51:27Dennis Sweeneysetmessageid: <1606719087.2.0.953559907215.issue42509@roundup.psfhosted.org>
2020-11-30 06:51:27Dennis Sweeneylinkissue42509 messages
2020-11-30 06:51:26Dennis Sweeneycreate