https://github.com/python/cpython/commit/7a2d77c903f29d7ea08b870b8e3fa2130f667a59
commit: 7a2d77c903f29d7ea08b870b8e3fa2130f667a59
branch: main
author: Victor Stinner <[email protected]>
committer: vstinner <[email protected]>
date: 2024-09-19T22:32:01+02:00
summary:

test_cext, test_cppext: enable /W4 warnings on Windows (#124253)

Add an explicit cast to (void*) and add Py_UNUSED() to fix some
warnings in extension.c.

files:
M Lib/test/test_cext/extension.c
M Lib/test/test_cext/setup.py
M Lib/test/test_cppext/setup.py

diff --git a/Lib/test/test_cext/extension.c b/Lib/test/test_cext/extension.c
index eb23dbe20353ba..b76abe1d74c628 100644
--- a/Lib/test/test_cext/extension.c
+++ b/Lib/test/test_cext/extension.c
@@ -37,7 +37,13 @@ static PyMethodDef _testcext_methods[] = {
 
 
 static int
-_testcext_exec(PyObject *module)
+_testcext_exec(
+#ifdef __STDC_VERSION__
+    PyObject *module
+#else
+    PyObject *Py_UNUSED(module)
+#endif
+    )
 {
 #ifdef __STDC_VERSION__
     if (PyModule_AddIntMacro(module, __STDC_VERSION__) < 0) {
@@ -53,7 +59,7 @@ _testcext_exec(PyObject *module)
 }
 
 static PyModuleDef_Slot _testcext_slots[] = {
-    {Py_mod_exec, _testcext_exec},
+    {Py_mod_exec, (void*)_testcext_exec},
     {0, NULL}
 };
 
diff --git a/Lib/test/test_cext/setup.py b/Lib/test/test_cext/setup.py
index 19edc5e663c55d..e97749b45ea6f3 100644
--- a/Lib/test/test_cext/setup.py
+++ b/Lib/test/test_cext/setup.py
@@ -31,6 +31,8 @@
 else:
     # MSVC compiler flags
     CFLAGS = [
+        # Display warnings level 1 to 4
+        '/W4',
         # Treat all compiler warnings as compiler errors
         '/WX',
     ]
diff --git a/Lib/test/test_cppext/setup.py b/Lib/test/test_cppext/setup.py
index f1848f2fd42a46..d97b238b8d1477 100644
--- a/Lib/test/test_cppext/setup.py
+++ b/Lib/test/test_cppext/setup.py
@@ -22,6 +22,8 @@
 else:
     # MSVC compiler flags
     CPPFLAGS = [
+        # Display warnings level 1 to 4
+        '/W4',
         # Treat all compiler warnings as compiler errors
         '/WX',
     ]

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: [email protected]

Reply via email to