[Python-checkins] gh-91321: Fix test_cppext for C++03 (#93902)

vstinner webhook-mailer at python.org
Thu Jun 16 08:39:26 EDT 2022


https://github.com/python/cpython/commit/a38c2a61d585fce0973e93dd590551ccddd947fb
commit: a38c2a61d585fce0973e93dd590551ccddd947fb
branch: main
author: Victor Stinner <vstinner at python.org>
committer: vstinner <vstinner at python.org>
date: 2022-06-16T14:39:00+02:00
summary:

gh-91321: Fix test_cppext for C++03 (#93902)

Don't build _testcppext.cpp with -Wzero-as-null-pointer-constant when
testing C++03: only use this compiler flag with C++11.

files:
M Lib/test/setup_testcppext.py

diff --git a/Lib/test/setup_testcppext.py b/Lib/test/setup_testcppext.py
index a288dbdc57bde..892e24a6376c5 100644
--- a/Lib/test/setup_testcppext.py
+++ b/Lib/test/setup_testcppext.py
@@ -19,8 +19,6 @@
         '-Werror',
         # Warn on old-style cast (C cast) like: (PyObject*)op
         '-Wold-style-cast',
-        # Warn when using NULL rather than _Py_NULL in static inline functions
-        '-Wzero-as-null-pointer-constant',
     ]
 else:
     # Don't pass any compiler flag to MSVC
@@ -39,6 +37,10 @@ def main():
         name = '_testcpp11ext'
 
     cppflags = [*CPPFLAGS, f'-std={std}']
+    if std == 'c++11':
+        # Warn when using NULL rather than _Py_NULL in static inline functions
+        cppflags.append('-Wzero-as-null-pointer-constant')
+
     cpp_ext = Extension(
         name,
         sources=[SOURCE],



More information about the Python-checkins mailing list