Skip to content

Commit 5ffbce7

Browse files
authored
gh-160473: Improve performance of exception raise (#160476)
1 parent 4aab0c4 commit 5ffbce7

1 file changed

Lines changed: 2 additions & 4 deletions

File tree

‎Python/errors.c‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ void
154154
_PyErr_SetObject(PyThreadState *tstate, PyObject *exception, PyObject *value)
155155
{
156156
PyObject *exc_value;
157-
PyObject *tb = NULL;
158157

159158
if (exception != NULL &&
160159
!PyExceptionClass_Check(exception)) {
@@ -237,9 +236,8 @@ _PyErr_SetObject(PyThreadState *tstate, PyObject *exception, PyObject *value)
237236
}
238237
}
239238
assert(value != NULL);
240-
if (PyExceptionInstance_Check(value))
241-
tb = PyException_GetTraceback(value);
242-
_PyErr_Restore(tstate, Py_NewRef(Py_TYPE(value)), value, tb);
239+
assert(PyExceptionInstance_Check(value));
240+
_PyErr_SetRaisedException(tstate, value);
243241
}
244242

245243
void

0 commit comments

Comments
 (0)