mirror of
https://github.com/python/cpython.git
synced 2025-11-24 20:30:18 +00:00
[3.14] gh-132775: Clean Up Cross-Interpreter Error Handling (gh-135492)
In this refactor we:
* move some code around
* make a couple of typedefs opaque
* decouple errors from session state
* improve tracebacks for propagated exceptions
This change helps simplify several upcoming changes.
(cherry picked from commit c7f4a80079, AKA gh-135369)
Co-authored-by: Eric Snow <ericsnowcurrently@gmail.com>
This commit is contained in:
parent
f77a911c52
commit
0fe5463877
6 changed files with 1359 additions and 1128 deletions
|
|
@ -7,13 +7,6 @@ _ensure_current_cause(PyThreadState *tstate, PyObject *cause)
|
|||
}
|
||||
PyObject *exc = _PyErr_GetRaisedException(tstate);
|
||||
assert(exc != NULL);
|
||||
PyObject *ctx = PyException_GetContext(exc);
|
||||
if (ctx == NULL) {
|
||||
PyException_SetContext(exc, Py_NewRef(cause));
|
||||
}
|
||||
else {
|
||||
Py_DECREF(ctx);
|
||||
}
|
||||
assert(PyException_GetCause(exc) == NULL);
|
||||
PyException_SetCause(exc, Py_NewRef(cause));
|
||||
_PyErr_SetRaisedException(tstate, exc);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue