davidmalcolm / gcc-python-plugin

GCC plugin that embeds CPython inside the compiler
GNU General Public License v3.0
197 stars 58 forks source link

PyObject_Length not considered setting exception #162

Open dvarrazzo opened 5 years ago

dvarrazzo commented 5 years ago

The following function:

static PyObject *
psyco_curs_callproc(cursorObject *self, PyObject *args)
{
    PyObject *parameters = NULL;
    Py_ssize_t nparameters = 0;

    if (!PyArg_ParseTuple(args, "O", &parameters)) {
        goto exit;
    }

    nparameters = PyObject_Length(parameters);
    if (nparameters == -1) { return NULL; }

    Py_RETURN_NONE;
}

returns a false positive, stating that if PyObject_Length fails the function returns without an exception.

image