cpython: 5e50f1a0c985 (original) (raw)

Mercurial > cpython

changeset 84570:5e50f1a0c985

Issue #18408: In debug mode, PyCFunction_Call() now checks if an exception was raised if the result is NULL to help to find bugs in C mode (get the error earlier than the SystemError in ceval.c). [#18408]

Victor Stinner victor.stinner@gmail.com
date Thu, 11 Jul 2013 23:44:46 +0200
parents 51eddca9dd6f
children 4975bcd67aa7
files Objects/methodobject.c
diffstat 1 files changed, 23 insertions(+), 7 deletions(-)[+] [-] Objects/methodobject.c 30

line wrap: on

line diff

--- a/Objects/methodobject.c +++ b/Objects/methodobject.c @@ -79,23 +79,34 @@ PyCFunction_GetFlags(PyObject *op) PyObject * PyCFunction_Call(PyObject *func, PyObject arg, PyObject kw) { +#define CHECK_RESULT(res) assert(res != NULL || PyErr_Occurred()) + PyCFunctionObject f = (PyCFunctionObject)func; PyCFunction meth = PyCFunction_GET_FUNCTION(func); PyObject *self = PyCFunction_GET_SELF(func);

@@ -105,8 +116,11 @@ PyCFunction_Call(PyObject *func, PyObjec case METH_O: if (kw == NULL || PyDict_Size(kw) == 0) { size = PyTuple_GET_SIZE(arg);

@@ -123,6 +137,8 @@ PyCFunction_Call(PyObject func, PyObjec PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments", f->m_ml->ml_name); return NULL; + +#undef CHECK_RESULT } / Methods (the standard built-in methods, that is) */