Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 48589:1ec38b707cd6
Merged revisions 65320 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65320 | amaury.forgeotdarc | 2008-07-30 19:42:16 -0500 (Wed, 30 Jul 2008) | 3 lines
#2542: now that issubclass() may call arbitrary code,
make sure that PyErr_ExceptionMatches returns 0 when an exception occurs there.
........
| author | Benjamin Peterson <benjamin@python.org> |
|---|---|
| date | Thu, 31 Jul 2008 01:47:08 +0000 |
| parents | 2ee09afee126 |
| children | de75e7280b7a |
comparison
equal
deleted
inserted
replaced
| 48588:9154553f876b | 48589:1ec38b707cd6 |
|---|---|
| 155 /* err might be an instance, so check its class. */ | 155 /* err might be an instance, so check its class. */ |
| 156 if (PyExceptionInstance_Check(err)) | 156 if (PyExceptionInstance_Check(err)) |
| 157 err = PyExceptionInstance_Class(err); | 157 err = PyExceptionInstance_Class(err); |
| 158 | 158 |
| 159 if (PyExceptionClass_Check(err) && PyExceptionClass_Check(exc)) { | 159 if (PyExceptionClass_Check(err) && PyExceptionClass_Check(exc)) { |
| 160 /* problems here!? not sure PyObject_IsSubclass expects to | 160 int res = 0; |
| 161 be called with an exception pending... */ | 161 PyObject *exception, *value, *tb; |
| 162 return PyObject_IsSubclass(err, exc); | 162 PyErr_Fetch(&exception, &value, &tb); |
| 163 res = PyObject_IsSubclass(err, exc); | |
| 164 /* This function must not fail, so print the error here */ | |
| 165 if (res == -1) { | |
| 166 PyErr_WriteUnraisable(err); | |
| 167 /* issubclass did not succeed */ | |
| 168 res = 0; | |
| 169 } | |
| 170 PyErr_Restore(exception, value, tb); | |
| 171 return res; | |
| 163 } | 172 } |
| 164 | 173 |
| 165 return err == exc; | 174 return err == exc; |
| 166 } | 175 } |
| 167 | 176 |
