bpo-33012: Fix invalid function cast warnings with gcc 8 for METH_NOARGS. (GH-6030)
METH_NOARGS functions need only a single argument but they are cast
into a PyCFunction, which takes two arguments. This triggers an
invalid function cast warning in gcc8 due to the argument mismatch.
Fix this by adding a dummy unused argument.
diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c
index f600179..9f492e4 100644
--- a/Objects/weakrefobject.c
+++ b/Objects/weakrefobject.c
@@ -452,7 +452,7 @@
#define WRAP_METHOD(method, special) \
static PyObject * \
- method(PyObject *proxy) { \
+ method(PyObject *proxy, PyObject *Py_UNUSED(ignored)) { \
_Py_IDENTIFIER(special); \
UNWRAP(proxy); \
return _PyObject_CallMethodId(proxy, &PyId_##special, NULL); \
@@ -602,7 +602,7 @@
static PyMethodDef proxy_methods[] = {
- {"__bytes__", (PyCFunction)proxy_bytes, METH_NOARGS},
+ {"__bytes__", proxy_bytes, METH_NOARGS},
{NULL, NULL}
};