Skip to content

Commit c6e418d

Browse files
authored
gh-141563: Enable test_cppext internal C API tests on macOS (#144711)
Build the C API in C++11 mode on macOS.
1 parent 3718f4b commit c6e418d

File tree

3 files changed

+14
-7
lines changed

3 files changed

+14
-7
lines changed

Lib/test/test_cppext/__init__.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import shlex
55
import shutil
66
import subprocess
7+
import sys
78
import unittest
89
from test import support
910

@@ -27,9 +28,6 @@
2728
class BaseTests:
2829
TEST_INTERNAL_C_API = False
2930

30-
def test_build(self):
31-
self.check_build('_testcppext')
32-
3331
def check_build(self, extension_name, std=None, limited=False):
3432
venv_dir = 'env'
3533
with support.setup_venv_with_pip_setuptools(venv_dir) as python_exe:
@@ -91,6 +89,9 @@ def run_cmd(operation, cmd):
9189

9290

9391
class TestPublicCAPI(BaseTests, unittest.TestCase):
92+
def test_build(self):
93+
self.check_build('_testcppext')
94+
9495
@support.requires_gil_enabled('incompatible with Free Threading')
9596
def test_build_limited_cpp03(self):
9697
self.check_build('_test_limited_cpp03ext', std='c++03', limited=True)
@@ -119,6 +120,13 @@ def test_build_cpp14(self):
119120
class TestInteralCAPI(BaseTests, unittest.TestCase):
120121
TEST_INTERNAL_C_API = True
121122

123+
def test_build(self):
124+
kwargs = {}
125+
if sys.platform == 'darwin':
126+
# Old Apple clang++ default C++ std is gnu++98
127+
kwargs['std'] = 'c++11'
128+
self.check_build('_testcppext_internal', **kwargs)
129+
122130

123131
if __name__ == "__main__":
124132
unittest.main()

Lib/test/test_cppext/extension.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,8 @@
1616
#ifdef TEST_INTERNAL_C_API
1717
// gh-135906: Check for compiler warnings in the internal C API
1818
# include "internal/pycore_frame.h"
19-
// mimalloc emits compiler warnings when Python is built on Windows
20-
// and macOS.
21-
# if !defined(MS_WINDOWS) && !defined(__APPLE__)
19+
// mimalloc emits compiler warnings on Windows.
20+
# if !defined(MS_WINDOWS)
2221
# include "internal/pycore_backoff.h"
2322
# include "internal/pycore_cell.h"
2423
# endif

Lib/test/test_cppext/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ def main():
5959
else:
6060
cppflags.append(f'-std={std}')
6161

62-
if limited or (std != 'c++03'):
62+
if limited or (std != 'c++03') and not internal:
6363
# See CPPFLAGS_PEDANTIC docstring
6464
cppflags.extend(CPPFLAGS_PEDANTIC)
6565

0 commit comments

Comments
 (0)