[Python-checkins] bpo-33012: Fix compilation warnings in memoryobject.c and _collectionsmodule.c (GH-12179)

Victor Stinner webhook-mailer at python.org
Tue Mar 5 10:10:57 EST 2019


https://github.com/python/cpython/commit/359a2f3daba49fde0d3a07fb3c7a8b051c450d08
commit: 359a2f3daba49fde0d3a07fb3c7a8b051c450d08
branch: master
author: Stéphane Wirtel <stephane at wirtel.be>
committer: Victor Stinner <vstinner at redhat.com>
date: 2019-03-05T16:10:53+01:00
summary:

bpo-33012: Fix compilation warnings in memoryobject.c and _collectionsmodule.c (GH-12179)

Cast function pointers to (void(*)(void)) before casting to (PyCFunction)
to make "warning: cast between incompatible function types" false alarm quiet.

files:
M Modules/_collectionsmodule.c
M Objects/memoryobject.c

diff --git a/Modules/_collectionsmodule.c b/Modules/_collectionsmodule.c
index 1c9e866e62f0..afd2731b8264 100644
--- a/Modules/_collectionsmodule.c
+++ b/Modules/_collectionsmodule.c
@@ -2453,7 +2453,7 @@ static PyMemberDef tuplegetter_members[] = {
 };
 
 static PyMethodDef tuplegetter_methods[] = {
-    {"__reduce__", (PyCFunction) tuplegetter_reduce, METH_NOARGS, NULL},
+    {"__reduce__", (PyCFunction)(void(*)(void))tuplegetter_reduce, METH_NOARGS, NULL},
     {NULL},
 };
 
diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c
index d835704bdaae..6bbb413c3c10 100644
--- a/Objects/memoryobject.c
+++ b/Objects/memoryobject.c
@@ -3109,7 +3109,7 @@ Return a readonly version of the memoryview.");
 
 static PyMethodDef memory_methods[] = {
     {"release",     (PyCFunction)memory_release, METH_NOARGS, memory_release_doc},
-    {"tobytes",     (PyCFunction)memory_tobytes, METH_VARARGS|METH_KEYWORDS, memory_tobytes_doc},
+    {"tobytes",     (PyCFunction)(void(*)(void))memory_tobytes, METH_VARARGS|METH_KEYWORDS, memory_tobytes_doc},
     {"hex",         (PyCFunction)memory_hex, METH_NOARGS, memory_hex_doc},
     {"tolist",      (PyCFunction)memory_tolist, METH_NOARGS, memory_tolist_doc},
     {"cast",        (PyCFunction)(void(*)(void))memory_cast, METH_VARARGS|METH_KEYWORDS, memory_cast_doc},



More information about the Python-checkins mailing list