Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

bpo-32604: [_xxsubinterpreters] Propagate exceptions. #19768

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
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
Set __context__ manually.
  • Loading branch information
ericsnowcurrently committed Apr 28, 2020
commit 5407cefcdf98178c3fa820dd0925dd2e4ca93d22
25 changes: 3 additions & 22 deletions 25 Modules/_xxsubinterpretersmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1135,26 +1135,6 @@ _sharedexception_extract(_sharedexception *she, PyObject *exc)
Py_XDECREF(msgobj);
}

static void
_pyexc_set_context(PyObject *exc, PyObject *context)
{
PyObject *contexttype = (PyObject *)Py_TYPE(context);

// PyErr_Restore() steals references.
PyObject *exctype = (PyObject *)Py_TYPE(exc);
Py_INCREF(exctype);
Py_INCREF(exc);
PyObject *tb = PyException_GetTraceback(exc);
PyErr_Restore(exctype, exc, tb); // This is needed for chaining.

Py_INCREF(contexttype); // _PyErr_ChainExceptions() steals a reference.
// This sets exc.__context__ to "context".
_PyErr_ChainExceptions(contexttype, context,
PyException_GetTraceback(context));

PyErr_Clear(); // We had only set it temporarily for chaining.
}

static PyObject *
_sharedexception_resolve(_sharedexception *sharedexc, PyObject *wrapperclass)
{
Expand All @@ -1167,8 +1147,9 @@ _sharedexception_resolve(_sharedexception *sharedexc, PyObject *wrapperclass)
// Set __cause__, is possible.
PyObject *cause = _sharedexception_get_cause(sharedexc);
if (cause != NULL) {
// Set __context__ automatically.
_pyexc_set_context(exc, cause);
// Set __context__.
Py_INCREF(cause); // PyException_SetContext() steals a reference.
PyException_SetContext(exc, cause);

// Set __cause__.
Py_INCREF(cause); // PyException_SetCause() steals a reference.
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.