mirror of
https://github.com/python/cpython.git
synced 2025-11-01 06:01:29 +00:00
GH-101578: Normalize the current exception (GH-101607)
* Make sure that the current exception is always normalized. * Remove redundant type and traceback fields for the current exception. * Add new API functions: PyErr_GetRaisedException, PyErr_SetRaisedException * Add new API functions: PyException_GetArgs, PyException_SetArgs
This commit is contained in:
parent
027adf42cd
commit
feec49c407
29 changed files with 477 additions and 172 deletions
|
|
@ -20,7 +20,10 @@ extern void _PyErr_FiniTypes(PyInterpreterState *);
|
|||
static inline PyObject* _PyErr_Occurred(PyThreadState *tstate)
|
||||
{
|
||||
assert(tstate != NULL);
|
||||
return tstate->curexc_type;
|
||||
if (tstate->current_exception == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
return (PyObject *)Py_TYPE(tstate->current_exception);
|
||||
}
|
||||
|
||||
static inline void _PyErr_ClearExcState(_PyErr_StackItem *exc_state)
|
||||
|
|
@ -37,10 +40,16 @@ PyAPI_FUNC(void) _PyErr_Fetch(
|
|||
PyObject **value,
|
||||
PyObject **traceback);
|
||||
|
||||
extern PyObject *
|
||||
_PyErr_GetRaisedException(PyThreadState *tstate);
|
||||
|
||||
PyAPI_FUNC(int) _PyErr_ExceptionMatches(
|
||||
PyThreadState *tstate,
|
||||
PyObject *exc);
|
||||
|
||||
void
|
||||
_PyErr_SetRaisedException(PyThreadState *tstate, PyObject *exc);
|
||||
|
||||
PyAPI_FUNC(void) _PyErr_Restore(
|
||||
PyThreadState *tstate,
|
||||
PyObject *type,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue