summaryrefslogtreecommitdiffstats
path: root/Python/errors.c
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2009-04-02 02:47:44 (GMT)
committerGeorg Brandl <georg@python.org>2009-04-02 02:47:44 (GMT)
commit4b5c53aba596f96eebf5b04efad8192f3ff0d4bf (patch)
tree5152808b9e20a5693c84451fca24759fa83eb27e /Python/errors.c
parent4724f40bcb69a4a1f84ba61918c14a8f0082a9ac (diff)
downloadcpython-4b5c53aba596f96eebf5b04efad8192f3ff0d4bf.zip
cpython-4b5c53aba596f96eebf5b04efad8192f3ff0d4bf.tar.gz
cpython-4b5c53aba596f96eebf5b04efad8192f3ff0d4bf.tar.bz2
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.
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/Python/errors.c b/Python/errors.c
index c88a190..02e9572 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -106,10 +106,16 @@ PyErr_GivenExceptionMatches(PyObject *err, PyObject *exc)
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);