https://github.com/python/cpython/commit/5ffbce74e37c170e0af643f1188d4c9c568fccda
commit: 5ffbce74e37c170e0af643f1188d4c9c568fccda
branch: main
author: Pieter Eendebak <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2026-10-31T12:29:27Z
summary:

gh-160473: Improve performance of exception raise (#160476)

files:
M Python/errors.c

diff --git a/Python/errors.c b/Python/errors.c
index 0645c688a9af7ed..74fd2f0502f69c6 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -154,7 +154,6 @@ void
 _PyErr_SetObject(PyThreadState *tstate, PyObject *exception, PyObject *value)
 {
     PyObject *exc_value;
-    PyObject *tb = NULL;
 
     if (exception != NULL &&
         !PyExceptionClass_Check(exception)) {
@@ -237,9 +236,8 @@ _PyErr_SetObject(PyThreadState *tstate, PyObject 
*exception, PyObject *value)
         }
     }
     assert(value != NULL);
-    if (PyExceptionInstance_Check(value))
-        tb = PyException_GetTraceback(value);
-    _PyErr_Restore(tstate, Py_NewRef(Py_TYPE(value)), value, tb);
+    assert(PyExceptionInstance_Check(value));
+    _PyErr_SetRaisedException(tstate, value);
 }
 
 void

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to