https://github.com/python/cpython/commit/a7ac7a8175ff64c2848f54644f5449ad44466a62
commit: a7ac7a8175ff64c2848f54644f5449ad44466a62
branch: main
author: Ruoyu Zhong <[email protected]>
committer: encukou <[email protected]>
date: 2026-10-28T15:29:15+01:00
summary:

gh-160704: Restore C11-C17 `static_assert` fallback (GH-160705)

`_Py_STDC_VERSION` needs to be defined before its value can be checked.
In 8335bcbf26b (gh-160208: Add a private wrapper around __STDC_VERSION__
(GH-160376), 2026-10-23), the condition `defined(_Py_STDC_VERSION)` is
incorrectly negated, which prevents the fallback definition of
`static_assert` in C11-C17 builds and causes a build error when building
with an old C library that does not define `static_assert`.

Signed-off-by: Ruoyu Zhong <[email protected]>

files:
A Misc/NEWS.d/next/Build/2026-10-26-21-00-00.gh-issue-160704.ZRYLKF.rst
M Include/pymacro.h

diff --git a/Include/pymacro.h b/Include/pymacro.h
index 73521be00fcd1ad..f08ed1a1ecf0f9f 100644
--- a/Include/pymacro.h
+++ b/Include/pymacro.h
@@ -25,7 +25,7 @@
 // behaviour. So only define if building as C, not C++ (if __cplusplus is
 // not defined), and only for C11-17.
 #if !defined(static_assert) && (defined(__GNUC__) || defined(__clang__)) \
-     && !defined(_Py_STDC_VERSION) \
+     && defined(_Py_STDC_VERSION) \
      && _Py_STDC_VERSION >= 201112L && _Py_STDC_VERSION <= 201710L
 #  define static_assert _Static_assert
 #endif
diff --git 
a/Misc/NEWS.d/next/Build/2026-10-26-21-00-00.gh-issue-160704.ZRYLKF.rst 
b/Misc/NEWS.d/next/Build/2026-10-26-21-00-00.gh-issue-160704.ZRYLKF.rst
new file mode 100644
index 000000000000000..330415c155cd89a
--- /dev/null
+++ b/Misc/NEWS.d/next/Build/2026-10-26-21-00-00.gh-issue-160704.ZRYLKF.rst
@@ -0,0 +1,2 @@
+Fix C11-C17 builds with old C library headers that do not define
+``static_assert``, including glibc versions older than 2.16.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to