Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 52711:7e86fa255fc2 legacy-trunk
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.
| author | Georg Brandl <georg@python.org> |
|---|---|
| date | Thu, 02 Apr 2009 02:47:44 +0000 |
| parents | d01c1d768841 |
| children | 54b2cd21ab46 |
comparison
equal
deleted
inserted
replaced
| 52710:b984456196af | 52711:7e86fa255fc2 |
|---|---|
| 104 /* err might be an instance, so check its class. */ | 104 /* err might be an instance, so check its class. */ |
| 105 if (PyExceptionInstance_Check(err)) | 105 if (PyExceptionInstance_Check(err)) |
| 106 err = PyExceptionInstance_Class(err); | 106 err = PyExceptionInstance_Class(err); |
| 107 | 107 |
| 108 if (PyExceptionClass_Check(err) && PyExceptionClass_Check(exc)) { | 108 if (PyExceptionClass_Check(err) && PyExceptionClass_Check(exc)) { |
| 109 int res = 0; | 109 int res = 0, reclimit; |
| 110 PyObject *exception, *value, *tb; | 110 PyObject *exception, *value, *tb; |
| 111 PyErr_Fetch(&exception, &value, &tb); | 111 PyErr_Fetch(&exception, &value, &tb); |
| 112 /* Temporarily bump the recursion limit, so that in the most | |
| 113 common case PyObject_IsSubclass will not raise a recursion | |
| 114 error we have to ignore anyway. */ | |
| 115 reclimit = Py_GetRecursionLimit(); | |
| 116 Py_SetRecursionLimit(reclimit + 5); | |
| 112 res = PyObject_IsSubclass(err, exc); | 117 res = PyObject_IsSubclass(err, exc); |
| 118 Py_SetRecursionLimit(reclimit); | |
| 113 /* This function must not fail, so print the error here */ | 119 /* This function must not fail, so print the error here */ |
| 114 if (res == -1) { | 120 if (res == -1) { |
| 115 PyErr_WriteUnraisable(err); | 121 PyErr_WriteUnraisable(err); |
| 116 res = 0; | 122 res = 0; |
| 117 } | 123 } |
