(original) (raw)

changeset: 52711:7e86fa255fc2 branch: legacy-trunk user: Georg Brandl georg@python.org date: Thu Apr 02 02:47:44 2009 +0000 files: Python/errors.c description: In PyErr_GivenExceptionMatches, temporarily bump the recursion limit, so that in the most common case PyObject_IsSubclass will not raise a recursion error we have to ignore anyway. diff -r b984456196af -r 7e86fa255fc2 Python/errors.c --- a/Python/errors.c Thu Apr 02 02:44:54 2009 +0000 +++ b/Python/errors.c Thu Apr 02 02:47:44 2009 +0000 @@ -106,10 +106,16 @@ err = PyExceptionInstance_Class(err); if (PyExceptionClass_Check(err) && PyExceptionClass_Check(exc)) { - int res = 0; + int res = 0, reclimit; PyObject *exception, *value, *tb; PyErr_Fetch(&exception, &value, &tb); + /* Temporarily bump the recursion limit, so that in the most + common case PyObject_IsSubclass will not raise a recursion + error we have to ignore anyway. */ + reclimit = Py_GetRecursionLimit(); + Py_SetRecursionLimit(reclimit + 5); res = PyObject_IsSubclass(err, exc); + Py_SetRecursionLimit(reclimit); /* This function must not fail, so print the error here */ if (res == -1) { PyErr_WriteUnraisable(err); /georg@python.org