From b641d4bbf15a4c062e703160d7db523e87e10201 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 19 Mar 2024 21:39:04 +0100 Subject: [PATCH 1/3] gh-116869: Fix test_cext for Free Threading --- Lib/test/test_cext/setup.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/Lib/test/test_cext/setup.py b/Lib/test/test_cext/setup.py index d6c4410fa5f1e3..1b0ad522c5f549 100644 --- a/Lib/test/test_cext/setup.py +++ b/Lib/test/test_cext/setup.py @@ -17,11 +17,14 @@ # The purpose of test_cext extension is to check that building a C # extension using the Python C API does not emit C compiler warnings. '-Werror', - - # gh-116869: The Python C API must be compatible with building - # with the -Werror=declaration-after-statement compiler flag. - '-Werror=declaration-after-statement', ] + # Free Threading doesn't build with -Werror=declaration-after-statement + if not sysconfig.get_config_var('Py_GIL_DISABLED'): + CFLAGS.append( + # gh-116869: The Python C API must be compatible with building + # with the -Werror=declaration-after-statement compiler flag. + '-Werror=declaration-after-statement', + ) else: # Don't pass any compiler flag to MSVC CFLAGS = [] From 821326d8c61819ccb28de2bc93ae84b611efbbd8 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 19 Mar 2024 22:02:34 +0100 Subject: [PATCH 2/3] Disable also -Werror on Free Threading --- Lib/test/test_cext/setup.py | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/Lib/test/test_cext/setup.py b/Lib/test/test_cext/setup.py index 1b0ad522c5f549..67ff29ff4fddfb 100644 --- a/Lib/test/test_cext/setup.py +++ b/Lib/test/test_cext/setup.py @@ -11,20 +11,17 @@ SOURCE = 'extension.c' -if not support.MS_WINDOWS: +if not support.MS_WINDOWS and not sysconfig.get_config_var('Py_GIL_DISABLED'): # C compiler flags for GCC and clang CFLAGS = [ # The purpose of test_cext extension is to check that building a C # extension using the Python C API does not emit C compiler warnings. '-Werror', + + # gh-116869: The Python C API must be compatible with building + # with the -Werror=declaration-after-statement compiler flag. + '-Werror=declaration-after-statement', ] - # Free Threading doesn't build with -Werror=declaration-after-statement - if not sysconfig.get_config_var('Py_GIL_DISABLED'): - CFLAGS.append( - # gh-116869: The Python C API must be compatible with building - # with the -Werror=declaration-after-statement compiler flag. - '-Werror=declaration-after-statement', - ) else: # Don't pass any compiler flag to MSVC CFLAGS = [] From 4096df8df71bb1bd7505fc3c6fb76a019d1e2015 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 19 Mar 2024 22:27:57 +0100 Subject: [PATCH 3/3] Skip more tests --- Lib/test/test_cext/__init__.py | 2 ++ Lib/test/test_cext/setup.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/Lib/test/test_cext/__init__.py b/Lib/test/test_cext/__init__.py index 7bf2381d844d1c..e4472b3355759c 100644 --- a/Lib/test/test_cext/__init__.py +++ b/Lib/test/test_cext/__init__.py @@ -40,9 +40,11 @@ def test_build_c11(self): def test_build_c99(self): self.check_build('_test_c99_cext', std='c99') + @unittest.skipIf(support.Py_GIL_DISABLED, 'incompatible with Free Threading') def test_build_limited(self): self.check_build('_test_limited_cext', limited=True) + @unittest.skipIf(support.Py_GIL_DISABLED, 'broken for now with Free Threading') def test_build_limited_c11(self): self.check_build('_test_limited_c11_cext', limited=True, std='c11') diff --git a/Lib/test/test_cext/setup.py b/Lib/test/test_cext/setup.py index 67ff29ff4fddfb..18f8d342787fd6 100644 --- a/Lib/test/test_cext/setup.py +++ b/Lib/test/test_cext/setup.py @@ -11,7 +11,7 @@ SOURCE = 'extension.c' -if not support.MS_WINDOWS and not sysconfig.get_config_var('Py_GIL_DISABLED'): +if not support.MS_WINDOWS and not support.Py_GIL_DISABLED: # C compiler flags for GCC and clang CFLAGS = [ # The purpose of test_cext extension is to check that building a C