PyErr_PrintEx() now uses fast call

Issue #27128.
This commit is contained in:
Victor Stinner 2016-08-20 00:57:43 +02:00
parent df142fdc4b
commit 71cb64acc2
1 changed files with 7 additions and 3 deletions

View File

@ -630,8 +630,13 @@ PyErr_PrintEx(int set_sys_last_vars)
} }
hook = _PySys_GetObjectId(&PyId_excepthook); hook = _PySys_GetObjectId(&PyId_excepthook);
if (hook) { if (hook) {
PyObject *args = PyTuple_Pack(3, exception, v, tb); PyObject* stack[3];
PyObject *result = PyEval_CallObject(hook, args); PyObject *result;
stack[0] = exception;
stack[1] = v;
stack[2] = tb;
result = _PyObject_FastCall(hook, stack, 3, NULL);
if (result == NULL) { if (result == NULL) {
PyObject *exception2, *v2, *tb2; PyObject *exception2, *v2, *tb2;
if (PyErr_ExceptionMatches(PyExc_SystemExit)) { if (PyErr_ExceptionMatches(PyExc_SystemExit)) {
@ -660,7 +665,6 @@ PyErr_PrintEx(int set_sys_last_vars)
Py_XDECREF(tb2); Py_XDECREF(tb2);
} }
Py_XDECREF(result); Py_XDECREF(result);
Py_XDECREF(args);
} else { } else {
PySys_WriteStderr("sys.excepthook is missing\n"); PySys_WriteStderr("sys.excepthook is missing\n");
PyErr_Display(exception, v, tb); PyErr_Display(exception, v, tb);