MCPcopy Create free account
hub / github.com/numpy/numpy / npy_PyErr_ChainExceptionsCause

Function npy_PyErr_ChainExceptionsCause

numpy/core/include/numpy/npy_3kcompat.h:475–500  ·  view source on GitHub ↗

This is a copy of _PyErr_ChainExceptions, with: * - a minimal implementation for python 2 * - __cause__ used instead of __context__ */

Source from the content-addressed store, hash-verified

473 * - __cause__ used instead of __context__
474 */
475static inline void
476npy_PyErr_ChainExceptionsCause(PyObject *exc, PyObject *val, PyObject *tb)
477{
478 if (exc == NULL)
479 return;
480
481 if (PyErr_Occurred()) {
482 /* only py3 supports this anyway */
483 #ifdef NPY_PY3K
484 PyObject *exc2, *val2, *tb2;
485 PyErr_Fetch(&exc2, &val2, &tb2);
486 PyErr_NormalizeException(&exc, &val, &tb);
487 if (tb != NULL) {
488 PyException_SetTraceback(val, tb);
489 Py_DECREF(tb);
490 }
491 Py_DECREF(exc);
492 PyErr_NormalizeException(&exc2, &val2, &tb2);
493 PyException_SetCause(val2, val);
494 PyErr_Restore(exc2, val2, tb2);
495 #endif
496 }
497 else {
498 PyErr_Restore(exc, val, tb);
499 }
500}
501
502/*
503 * PyObject_Cmp

Callers 6

PyArray_CastDescrToDTypeFunction · 0.85
DEPRECATE_silence_errorFunction · 0.85
read_rowsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected