summaryrefslogtreecommitdiffstats
path: root/Lib/test/test_cppext
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2024-03-19 21:58:13 (GMT)
committerGitHub <noreply@github.com>2024-03-19 21:58:13 (GMT)
commit438de10c160c188fced64317df9118100c329ffe (patch)
tree64a811a05772e9d96c992e7bbba01197e2dd1c92 /Lib/test/test_cppext
parent2d17309cc719c41e02ffd1d6cac10f95a7e2359c (diff)
downloadcpython-438de10c160c188fced64317df9118100c329ffe.zip
cpython-438de10c160c188fced64317df9118100c329ffe.tar.gz
cpython-438de10c160c188fced64317df9118100c329ffe.tar.bz2
gh-116869: Fix test_cext on RHEL7 (#117010)
Remove -std option from CC command line. Skip C++14 test for now on non-Windows platforms (like RHEL7).
Diffstat (limited to 'Lib/test/test_cppext')
-rw-r--r--Lib/test/test_cppext/__init__.py3
-rw-r--r--Lib/test/test_cppext/setup.py24
2 files changed, 17 insertions, 10 deletions
diff --git a/Lib/test/test_cppext/__init__.py b/Lib/test/test_cppext/__init__.py
index b8414f2..00a2840 100644
--- a/Lib/test/test_cppext/__init__.py
+++ b/Lib/test/test_cppext/__init__.py
@@ -35,6 +35,9 @@ class TestCPPExt(unittest.TestCase):
def test_build_cpp11(self):
self.check_build('_testcpp11ext', std='c++11')
+ # Only test C++14 on MSVC.
+ # On s390x RHEL7, GCC 4.8.5 doesn't support C++14.
+ @unittest.skipIf(not support.MS_WINDOWS, "need Windows")
def test_build_cpp14(self):
self.check_build('_testcpp14ext', std='c++14')
diff --git a/Lib/test/test_cppext/setup.py b/Lib/test/test_cppext/setup.py
index 77e47bc..80b3e0d 100644
--- a/Lib/test/test_cppext/setup.py
+++ b/Lib/test/test_cppext/setup.py
@@ -35,19 +35,23 @@ def main():
if std:
if support.MS_WINDOWS:
cppflags.append(f'/std:{std}')
- std_prefix = '/std'
else:
cppflags.append(f'-std={std}')
- std_prefix = '-std'
- # Remove existing -std options to only test ours
- cmd = (sysconfig.get_config_var('CC') or '')
- if cmd is not None:
- cmd = shlex.split(cmd)
- cmd = [arg for arg in cmd if not arg.startswith(std_prefix)]
- cmd = shlex.join(cmd)
- # CC env var overrides sysconfig CC variable in setuptools
- os.environ['CC'] = cmd
+ # gh-105776: When "gcc -std=11" is used as the C++ compiler, -std=c11
+ # option emits a C++ compiler warning. Remove "-std11" option from the
+ # CC command.
+ cmd = (sysconfig.get_config_var('CC') or '')
+ if cmd is not None:
+ if support.MS_WINDOWS:
+ std_prefix = '/std'
+ else:
+ std_prefix = '-std'
+ cmd = shlex.split(cmd)
+ cmd = [arg for arg in cmd if not arg.startswith(std_prefix)]
+ cmd = shlex.join(cmd)
+ # CC env var overrides sysconfig CC variable in setuptools
+ os.environ['CC'] = cmd
# On Windows, add PCbuild\amd64\ to include and library directories
include_dirs = []