cpython: 0c65a2089f00 (original) (raw)

Mercurial > cpython

changeset 102847:0c65a2089f00

Add _PyErr_CreateException() Issue #27809: Helper function optimized to create an exception: use fastcall whenever possible. [#27809]

Victor Stinner victor.stinner@gmail.com
date Mon, 22 Aug 2016 23:59:08 +0200
parents 5587d0dfab4c
children c53c532de995
files Python/errors.c
diffstat 1 files changed, 30 insertions(+), 31 deletions(-)[+] [-] Python/errors.c 61

line wrap: on

line diff

--- a/Python/errors.c +++ b/Python/errors.c @@ -52,6 +52,20 @@ PyErr_Restore(PyObject *type, PyObject Py_XDECREF(oldtraceback); } +static PyObject +_PyErr_CreateException(PyObject *exception, PyObject *value) +{

+} + void PyErr_SetObject(PyObject *exception, PyObject *value) { @@ -66,6 +80,7 @@ PyErr_SetObject(PyObject *exception, PyO exception); return; } + Py_XINCREF(value); exc_value = tstate->exc_value; if (exc_value != NULL && exc_value != Py_None) { @@ -73,28 +88,21 @@ PyErr_SetObject(PyObject exception, PyO Py_INCREF(exc_value); if (value == NULL || !PyExceptionInstance_Check(value)) { / We must normalize the value right now */

+ value = fixed_value; } + /* Avoid reference cycles through the context chain. This is O(chain length) but context chains are usually very short. Sensitive readers may try @@ -110,7 +118,8 @@ PyErr_SetObject(PyObject *exception, PyO o = context; } PyException_SetContext(value, exc_value);