Movatterモバイル変換


[0]ホーム

URL:


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

Sign up
Appearance settings

Commit27d2204

Browse files
committed
Treat warnings as errors on MSVC
1 parent6d8c17a commit27d2204

File tree

3 files changed

+51
-34
lines changed

3 files changed

+51
-34
lines changed

‎.github/workflows/build.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ jobs:
5353
-os:windows-latest
5454
python:3.6
5555
-os:windows-latest
56-
python:3.12
56+
python:3.13
5757

5858
# macOS: test only new Python
5959
-os:macos-latest

‎pythoncapi_compat.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1537,7 +1537,7 @@ static inline int PyUnicode_Equal(PyObject *str1, PyObject *str2)
15371537
}
15381538

15391539
#if PY_VERSION_HEX >= 0x030d0000 && !defined(PYPY_VERSION)
1540-
PyAPI_FUNC(int)_PyUnicode_Equal(PyObject *str1, PyObject *str2);
1540+
externint_PyUnicode_Equal(PyObject *str1, PyObject *str2);
15411541

15421542
return_PyUnicode_Equal(str1, str2);
15431543
#elif PY_VERSION_HEX >= 0x03060000 && !defined(PYPY_VERSION)
@@ -1564,7 +1564,7 @@ static inline PyObject* PyBytes_Join(PyObject *sep, PyObject *iterable)
15641564
staticinline Py_hash_tPy_HashBuffer(constvoid *ptr, Py_ssize_t len)
15651565
{
15661566
#if PY_VERSION_HEX >= 0x03000000 && !defined(PYPY_VERSION)
1567-
PyAPI_FUNC(Py_hash_t)_Py_HashBytes(constvoid *src, Py_ssize_t len);
1567+
externPy_hash_t_Py_HashBytes(constvoid *src, Py_ssize_t len);
15681568

15691569
return_Py_HashBytes(ptr, len);
15701570
#else

‎tests/setup.py

Lines changed: 48 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,53 @@
1313

1414

1515
# C++ is only supported on Python 3.6 and newer
16-
TEST_CPP= (sys.version_info>= (3,6))
16+
TEST_CXX= (sys.version_info>= (3,6))
1717

1818
SRC_DIR=os.path.normpath(os.path.join(os.path.dirname(__file__),'..'))
1919

2020
# Windows uses MSVC compiler
2121
MSVC= (os.name=="nt")
2222

23-
# C compiler flags for GCC and clang
24-
COMMON_FLAGS= [
25-
# Treat warnings as error
26-
'-Werror',
27-
# Enable all warnings
28-
'-Wall','-Wextra',
29-
# Extra warnings
30-
'-Wconversion',
31-
# /usr/lib64/pypy3.7/include/pyport.h:68:20: error: redefinition of typedef
32-
# 'Py_hash_t' is a C11 feature
33-
"-Wno-typedef-redefinition",
34-
]
35-
CFLAGS=COMMON_FLAGS+ [
36-
# Use C99 for pythoncapi_compat.c which initializes PyModuleDef with a
37-
# mixture of designated and non-designated initializers
38-
'-std=c99',
39-
]
40-
CPPFLAGS=list(COMMON_FLAGS)
41-
# FIXME: _Py_CAST() emits C++ compilers on Python 3.12.
42-
# See: https://github.com/python/cpython/issues/94731
43-
if0:
44-
CPPFLAGS.extend((
45-
'-Wold-style-cast',
46-
'-Wzero-as-null-pointer-constant',
47-
))
23+
ifnotMSVC:
24+
# C compiler flags for GCC and clang
25+
COMMON_FLAGS= [
26+
# Treat warnings as error
27+
'-Werror',
28+
# Enable all warnings
29+
'-Wall','-Wextra',
30+
# Extra warnings
31+
'-Wconversion',
32+
# /usr/lib64/pypy3.7/include/pyport.h:68:20: error: redefinition of typedef
33+
# 'Py_hash_t' is a C11 feature
34+
"-Wno-typedef-redefinition",
35+
]
36+
CFLAGS=COMMON_FLAGS+ [
37+
# Use C99 for pythoncapi_compat.c which initializes PyModuleDef with a
38+
# mixture of designated and non-designated initializers
39+
'-std=c99',
40+
]
41+
CXXFLAGS=list(COMMON_FLAGS)
42+
# FIXME: _Py_CAST() emits C++ compilers on Python 3.12.
43+
# See: https://github.com/python/cpython/issues/94731
44+
if0:
45+
CXXFLAGS.extend((
46+
'-Wold-style-cast',
47+
'-Wzero-as-null-pointer-constant',
48+
))
49+
else:
50+
COMMON_FLAGS= [
51+
# Treat all compiler warnings as compiler errors
52+
'/WX',
53+
]
54+
ifsys.version_info>= (3,13):
55+
COMMON_FLAGS.append(
56+
# Display warnings level 1 to 4
57+
'/W4'
58+
)
59+
CFLAGS=COMMON_FLAGS+ [
60+
'/std:c99'
61+
]
62+
CXXFLAGS=list(COMMON_FLAGS)
4863

4964

5065
defmain():
@@ -68,9 +83,8 @@ def main():
6883

6984
cflags= ['-I'+SRC_DIR]
7085
cppflags=list(cflags)
71-
ifnotMSVC:
72-
cflags.extend(CFLAGS)
73-
cppflags.extend(CPPFLAGS)
86+
cflags.extend(CFLAGS)
87+
cppflags.extend(CXXFLAGS)
7488

7589
# C extension
7690
c_ext=Extension(
@@ -79,7 +93,7 @@ def main():
7993
extra_compile_args=cflags)
8094
extensions= [c_ext]
8195

82-
ifTEST_CPP:
96+
ifTEST_CXX:
8397
# C++ extension
8498

8599
# MSVC has /std flag but doesn't support /std:c++11
@@ -89,7 +103,10 @@ def main():
89103
('test_pythoncapi_compat_cpp11ext','-std=c++11'),
90104
]
91105
else:
92-
versions= [('test_pythoncapi_compat_cppext',None)]
106+
versions= [
107+
('test_pythoncapi_compat_cpp03ext','/std:c++03'),
108+
('test_pythoncapi_compat_cpp11ext','/std:c++11'),
109+
]
93110
forname,flaginversions:
94111
flags=list(cppflags)
95112
ifflagisnotNone:

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp