Mercurial > cpython-lru_cache-weakref
comparison Python/errors.c @ 76418:9fdec1354af4
Issue #14098: New functions PyErr_GetExcInfo and PyErr_SetExcInfo.
Patch by Stefan Behnel.
| author | Martin v. Löwis <martin@v.loewis.de> |
|---|---|
| date | Thu, 19 Apr 2012 14:33:43 +0200 |
| parents | cb6811eb20ef |
| children | a281604a5c9a |
comparison
equal
deleted
inserted
replaced
| 76417:18abb0b338c8 | 76418:9fdec1354af4 |
|---|---|
| 316 | 316 |
| 317 void | 317 void |
| 318 PyErr_Clear(void) | 318 PyErr_Clear(void) |
| 319 { | 319 { |
| 320 PyErr_Restore(NULL, NULL, NULL); | 320 PyErr_Restore(NULL, NULL, NULL); |
| 321 } | |
| 322 | |
| 323 void | |
| 324 PyErr_GetExcInfo(PyObject **p_type, PyObject **p_value, PyObject **p_traceback) | |
| 325 { | |
| 326 PyThreadState *tstate = PyThreadState_GET(); | |
| 327 | |
| 328 *p_type = tstate->exc_type; | |
| 329 *p_value = tstate->exc_value; | |
| 330 *p_traceback = tstate->exc_traceback; | |
| 331 | |
| 332 Py_XINCREF(*p_type); | |
| 333 Py_XINCREF(*p_value); | |
| 334 Py_XINCREF(*p_traceback); | |
| 335 } | |
| 336 | |
| 337 void | |
| 338 PyErr_SetExcInfo(PyObject *p_type, PyObject *p_value, PyObject *p_traceback) | |
| 339 { | |
| 340 PyObject *oldtype, *oldvalue, *oldtraceback; | |
| 341 PyThreadState *tstate = PyThreadState_GET(); | |
| 342 | |
| 343 oldtype = tstate->exc_type; | |
| 344 oldvalue = tstate->exc_value; | |
| 345 oldtraceback = tstate->exc_traceback; | |
| 346 | |
| 347 tstate->exc_type = p_type; | |
| 348 tstate->exc_value = p_value; | |
| 349 tstate->exc_traceback = p_traceback; | |
| 350 | |
| 351 Py_XDECREF(oldtype); | |
| 352 Py_XDECREF(oldvalue); | |
| 353 Py_XDECREF(oldtraceback); | |
| 321 } | 354 } |
| 322 | 355 |
| 323 /* Convenience functions to set a type error exception and return 0 */ | 356 /* Convenience functions to set a type error exception and return 0 */ |
| 324 | 357 |
| 325 int | 358 int |
