This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ztane
Recipients cstratak, serhiy.storchaka, siddhesh, ztane
Date 2018-03-15.15:27:14
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
Yea, I looked into `ceval.c` and the function is *called incorrectly*, so there is undefined behaviour there - it has been wrong all along, in 3.5 all the way down to 2-something

        if (flags & (METH_NOARGS | METH_O)) {
            PyCFunction meth = PyCFunction_GET_FUNCTION(func);
            PyObject *self = PyCFunction_GET_SELF(func);
            if (flags & METH_NOARGS && na == 0) {
                C_TRACE(x, (*meth)(self,NULL));

                x = _Py_CheckFunctionResult(func, x, NULL);

The warning in GCC shouldn't probably have been enabled at all in `-Wall -Wextra` because the cast is explicit. However, it is somewhat true.

However, the correct way to fix would be to have the METH_NOARGS case cast the function to the right prototype. There exists lots of existing code that *is* going to break too. 

Perhaps PyCFunction should declare no prototype, i.e. empty parentheses, for backwards compatibility:

    typedef PyObject *(*PyCFunction)();

and deprecate it; start using a new typedef for it - and then add proper casts in every place that call a function.
Date User Action Args
2018-03-15 15:27:14ztanesetrecipients: + ztane, serhiy.storchaka, siddhesh, cstratak
2018-03-15 15:27:14ztanesetmessageid: <>
2018-03-15 15:27:14ztanelinkissue33012 messages
2018-03-15 15:27:14ztanecreate