]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-141563: Enable test_cppext internal C API tests on macOS (#144711)
authorVictor Stinner <vstinner@python.org>
Wed, 11 Feb 2026 17:38:23 +0000 (18:38 +0100)
committerGitHub <noreply@github.com>
Wed, 11 Feb 2026 17:38:23 +0000 (18:38 +0100)
Build the C API in C++11 mode on macOS.

Lib/test/test_cppext/__init__.py
Lib/test/test_cppext/extension.cpp
Lib/test/test_cppext/setup.py

index 9013503995bdcedd7ef6bf64d07015475234103d..1fd01702f64029bba8f277941886946c19fdb29e 100644 (file)
@@ -4,6 +4,7 @@ import os.path
 import shlex
 import shutil
 import subprocess
+import sys
 import unittest
 from test import support
 
@@ -27,9 +28,6 @@ SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
 class BaseTests:
     TEST_INTERNAL_C_API = False
 
-    def test_build(self):
-        self.check_build('_testcppext')
-
     def check_build(self, extension_name, std=None, limited=False):
         venv_dir = 'env'
         with support.setup_venv_with_pip_setuptools(venv_dir) as python_exe:
@@ -91,6 +89,9 @@ class BaseTests:
 
 
 class TestPublicCAPI(BaseTests, unittest.TestCase):
+    def test_build(self):
+        self.check_build('_testcppext')
+
     @support.requires_gil_enabled('incompatible with Free Threading')
     def test_build_limited_cpp03(self):
         self.check_build('_test_limited_cpp03ext', std='c++03', limited=True)
@@ -119,6 +120,13 @@ class TestPublicCAPI(BaseTests, unittest.TestCase):
 class TestInteralCAPI(BaseTests, unittest.TestCase):
     TEST_INTERNAL_C_API = True
 
+    def test_build(self):
+        kwargs = {}
+        if sys.platform == 'darwin':
+            # Old Apple clang++ default C++ std is gnu++98
+            kwargs['std'] = 'c++11'
+        self.check_build('_testcppext_internal', **kwargs)
+
 
 if __name__ == "__main__":
     unittest.main()
index 06ef997d57af463888e275897858172eac2dc475..92c4645039a03b4eb326ed5ce3256096a7af971e 100644 (file)
@@ -16,9 +16,8 @@
 #ifdef TEST_INTERNAL_C_API
    // gh-135906: Check for compiler warnings in the internal C API
 #  include "internal/pycore_frame.h"
-   // mimalloc emits compiler warnings when Python is built on Windows
-   // and macOS.
-#  if !defined(MS_WINDOWS) && !defined(__APPLE__)
+   // mimalloc emits compiler warnings on Windows.
+#  if !defined(MS_WINDOWS)
 #    include "internal/pycore_backoff.h"
 #    include "internal/pycore_cell.h"
 #  endif
index a3eec1c67e1556e0bd7f72744f791917f62d03fc..2d9052a6b879da90eaf16648f89b08dbba8e8ce7 100644 (file)
@@ -59,7 +59,7 @@ def main():
         else:
             cppflags.append(f'-std={std}')
 
-        if limited or (std != 'c++03'):
+        if limited or (std != 'c++03') and not internal:
             # See CPPFLAGS_PEDANTIC docstring
             cppflags.extend(CPPFLAGS_PEDANTIC)