Index: Python/ceval.c =================================================================== --- Python/ceval.c (revision 72313) +++ Python/ceval.c (working copy) @@ -601,17 +601,19 @@ return 0; if (tstate->overflowed) { if (tstate->recursion_depth > recursion_limit + 50) { - /* Overflowing while handling an overflow. Give up. */ - Py_FatalError("Cannot recover from stack overflow."); + /* Overflowing while handling an overflow. + * Use the prebuilt exception object. */ + PyErr_SetObject(PyExc_RuntimeError, PyExc_RecursionErrorInst); + --tstate->recursion_depth; + return -1; } - return 0; } if (tstate->recursion_depth > recursion_limit) { - --tstate->recursion_depth; tstate->overflowed = 1; PyErr_Format(PyExc_RuntimeError, "maximum recursion depth exceeded%s", where); + --tstate->recursion_depth; return -1; } return 0;