Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Add _PyXI_ResolveCapturedException().
  • Loading branch information
ericsnowcurrently committed Nov 6, 2023
commit 5e9b17e9d5abf7f9a8ed40cc104aba308057ffa2
3 changes: 3 additions & 0 deletions Include/internal/pycore_crossinterp.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,9 @@ PyAPI_FUNC(void) _PyXI_Exit(_PyXI_session *session);
PyAPI_FUNC(void) _PyXI_ApplyCapturedException(
_PyXI_session *session,
PyObject *excwrapper);
PyAPI_FUNC(PyObject *) _PyXI_ResolveCapturedException(
_PyXI_session *session,
PyObject *excwrapper);
PyAPI_FUNC(int) _PyXI_HasCapturedException(_PyXI_session *session);


Expand Down
20 changes: 20 additions & 0 deletions Python/crossinterp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1584,6 +1584,26 @@ _PyXI_HasCapturedException(_PyXI_session *session)
return session->exc != NULL;
}

PyObject *
_PyXI_ResolveCapturedException(_PyXI_session *session, PyObject *excwrapper)
{
assert(!PyErr_Occurred());
assert(session->exc != NULL);
PyObject *snapshot = NULL;
if (session->exc->code == _PyXI_ERR_UNCAUGHT_EXCEPTION) {
snapshot = PyExceptionSnapshot_FromInfo(&session->exc->uncaught);
if (snapshot == NULL) {
return NULL;
}
assert(!PyErr_Occurred());
}
else {
_PyXI_ApplyCapturedException(session, excwrapper);
assert(PyErr_Occurred());
}
return snapshot;
}

int
_PyXI_Enter(_PyXI_session *session,
PyInterpreterState *interp, PyObject *nsupdates)
Expand Down