Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9173b2b

Browse filesBrowse files
authored
gh-105776: Fix test_cppext when CC contains -std=c11 option (#108343)
Fix test_cppext when the C compiler command has the "-std=c11" option. Remove "-std=" options from the compiler command.
1 parent 3a1ac87 commit 9173b2b
Copy full SHA for 9173b2b

File tree

Expand file treeCollapse file tree

2 files changed

+15
-0
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-0
lines changed

‎Lib/test/test_cppext/setup.py

Copy file name to clipboardExpand all lines: Lib/test/test_cppext/setup.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# gh-91321: Build a basic C++ test extension to check that the Python C API is
22
# compatible with C++ and does not emit C++ compiler warnings.
33
import os
4+
import shlex
45
import sys
6+
import sysconfig
57

68
from setuptools import setup, Extension
79

@@ -30,6 +32,17 @@ def main():
3032

3133
cppflags = [*CPPFLAGS, f'-std={std}']
3234

35+
# gh-105776: When "gcc -std=11" is used as the C++ compiler, -std=c11
36+
# option emits a C++ compiler warning. Remove "-std11" option from the
37+
# CC command.
38+
cmd = (sysconfig.get_config_var('CC') or '')
39+
if cmd is not None:
40+
cmd = shlex.split(cmd)
41+
cmd = [arg for arg in cmd if not arg.startswith('-std=')]
42+
cmd = shlex.join(cmd)
43+
# CC env var overrides sysconfig CC variable in setuptools
44+
os.environ['CC'] = cmd
45+
3346
cpp_ext = Extension(
3447
name,
3548
sources=[SOURCE],
+2Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix test_cppext when the C compiler command ``-std=c11`` option: remove
2+
``-std=`` options from the compiler command. Patch by Victor Stinner.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.