diff mbox series

python3: backport the fix for _Py_STDC_VERSION in pyport.h

Message ID 20261121160050.1531479-1-f_l_k@t-online.de
State New
Headers show
Series python3: backport the fix for _Py_STDC_VERSION in pyport.h | expand

Commit Message

Markus Volk Nov. 21, 2026, 3:59 p.m. UTC
pyport.h tests _Py_STDC_VERSION without defined(), so code built with
-Werror=undef fails on the Python 3.15 headers; libpeas is one of them.
Backport the fix from the 3.15 branch.

AI-Generated: Uses Claude Code (Claude Opus 5.5)
Signed-off-by: Markus Volk <f_l_k@t-online.de>
---
 ...ly-use-_Py_STDC_VERSION-when-defined.patch | 79 +++++++++++++++++++
 .../recipes-devtools/python/python3_3.15.2.bb |  1 +
 2 files changed, 80 insertions(+)
 create mode 100644 meta/recipes-devtools/python/python3/0001-3.15-gh-154643-Only-use-_Py_STDC_VERSION-when-defined.patch

Comments

patchtest@automation.yoctoproject.org Nov. 21, 2026, 4:16 p.m. UTC | #1
Thank you for your submission. Patchtest identified one
or more issues with the patch. Please see the log below for
more information:

---
Testing patch /home/patchtest/share/mboxes/python3-backport-the-fix-for-_Py_STDC_VERSION-in-pyport.h.patch

FAIL: test Signed-off-by presence: A patch file has been added without a Signed-off-by tag: '0001-3.15-gh-154643-Only-use-_Py_STDC_VERSION-when-defined.patch' (test_patch.TestPatch.test_signed_off_by_presence)

PASS: pretest src uri left files (test_metadata.TestMetadata.pretest_src_uri_left_files)
PASS: test CVE check ignore (test_metadata.TestMetadata.test_cve_check_ignore)
PASS: test CVE tag format (test_patch.TestPatch.test_cve_tag_format)
PASS: test Signed-off-by presence (test_mbox.TestMbox.test_signed_off_by_presence)
PASS: test Upstream-Status presence (test_patch.TestPatch.test_upstream_status_presence_format)
PASS: test auh changelog truncation notice (test_mbox.TestMbox.test_auh_changelog_truncation_notice)
PASS: test author valid (test_mbox.TestMbox.test_author_valid)
PASS: test commit message presence (test_mbox.TestMbox.test_commit_message_presence)
PASS: test commit message user tags (test_mbox.TestMbox.test_commit_message_user_tags)
PASS: test lic files chksum modified not mentioned (test_metadata.TestMetadata.test_lic_files_chksum_modified_not_mentioned)
PASS: test max line length (test_metadata.TestMetadata.test_max_line_length)
PASS: test mbox format (test_mbox.TestMbox.test_mbox_format)
PASS: test non-AUH upgrade (test_mbox.TestMbox.test_non_auh_upgrade)
PASS: test shortlog format (test_mbox.TestMbox.test_shortlog_format)
PASS: test shortlog length (test_mbox.TestMbox.test_shortlog_length)
PASS: test src uri left files (test_metadata.TestMetadata.test_src_uri_left_files)
PASS: test target mailing list (test_mbox.TestMbox.test_target_mailing_list)

SKIP: pretest pylint: No python related patches, skipping test (test_python_pylint.PyLint.pretest_pylint)
SKIP: test bugzilla entry format: No bug ID found (test_mbox.TestMbox.test_bugzilla_entry_format)
SKIP: test lic files chksum presence: No added recipes, skipping test (test_metadata.TestMetadata.test_lic_files_chksum_presence)
SKIP: test license presence: No added recipes, skipping test (test_metadata.TestMetadata.test_license_presence)
SKIP: test pylint: No python related patches, skipping test (test_python_pylint.PyLint.test_pylint)
SKIP: test series merge on head: Merge test is disabled for now (test_mbox.TestMbox.test_series_merge_on_head)
SKIP: test summary presence: No added recipes, skipping test (test_metadata.TestMetadata.test_summary_presence)

---

Please address the issues identified and
submit a new revision of the patch, or alternatively, reply to this
email with an explanation of why the patch should be accepted. If you
believe these results are due to an error in patchtest, please submit a
bug at https://bugzilla.yoctoproject.org/ (use the 'Patchtest' category
under 'Yocto Project Subprojects'). For more information on specific
failures, see: https://wiki.yoctoproject.org/wiki/Patchtest. Thank
you!
diff mbox series

Patch

diff --git a/meta/recipes-devtools/python/python3/0001-3.15-gh-154643-Only-use-_Py_STDC_VERSION-when-defined.patch b/meta/recipes-devtools/python/python3/0001-3.15-gh-154643-Only-use-_Py_STDC_VERSION-when-defined.patch
new file mode 100644
index 0000000000..5df7cd2f9c
--- /dev/null
+++ b/meta/recipes-devtools/python/python3/0001-3.15-gh-154643-Only-use-_Py_STDC_VERSION-when-defined.patch
@@ -0,0 +1,79 @@ 
+From beff3c022fe787f6879c7e38a6b8a64243184ab3 Mon Sep 17 00:00:00 2001
+From: "Miss Islington (bot)"
+ <31488909+miss-islington@users.noreply.github.com>
+Date: Thu, 12 Nov 2026 07:39:16 -0800
+Subject: [PATCH] [3.15] gh-154643: Only use _Py_STDC_VERSION when defined
+ (GH-154650) (GH-161874)
+MIME-Version: 1.0
+Content-Type: text/plain; charset=UTF-8
+Content-Transfer-Encoding: 8bit
+
+Co-authored-by: Miro HronĨok <miro@hroncok.cz>
+
+Upstream-Status: Backport [https://github.com/python/cpython/commit/beff3c022fe787f6879c7e38a6b8a64243184ab3]
+---
+ Include/cpython/pyatomic.h                                  | 2 +-
+ Include/pyport.h                                            | 2 +-
+ Lib/test/test_cext/setup.py                                 | 6 ++++++
+ .../C_API/2026-07-24-22-30-40.gh-issue-154643.z-ZutK.rst    | 2 ++
+ 4 files changed, 10 insertions(+), 2 deletions(-)
+ create mode 100644 Misc/NEWS.d/next/C_API/2026-07-24-22-30-40.gh-issue-154643.z-ZutK.rst
+
+diff --git a/Include/cpython/pyatomic.h b/Include/cpython/pyatomic.h
+index 71a76bdc82ce475..0a11f7781f07e00 100644
+--- a/Include/cpython/pyatomic.h
++++ b/Include/cpython/pyatomic.h
+@@ -585,7 +585,7 @@ static inline void _Py_atomic_fence_release(void);
+ #  define Py_ATOMIC_GCC_H
+ #  include "pyatomic_gcc.h"
+ #  undef Py_ATOMIC_GCC_H
+-#elif _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_ATOMICS__)
++#elif defined(_Py_STDC_VERSION) && _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_ATOMICS__)
+ #  define Py_ATOMIC_STD_H
+ #  include "pyatomic_std.h"
+ #  undef Py_ATOMIC_STD_H
+diff --git a/Include/pyport.h b/Include/pyport.h
+index 6bf011e87709cc0..44d76511fbffbe2 100644
+--- a/Include/pyport.h
++++ b/Include/pyport.h
+@@ -491,7 +491,7 @@ extern "C" {
+ #ifdef WITH_THREAD
+ #  ifdef thread_local
+ #    define _Py_thread_local thread_local
+-#  elif _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_THREADS__)
++#  elif defined(_Py_STDC_VERSION) && _Py_STDC_VERSION >= 201112L && !defined(__STDC_NO_THREADS__)
+ #    define _Py_thread_local _Thread_local
+ #  elif defined(_MSC_VER)  /* AKA NT_THREADS */
+ #    define _Py_thread_local __declspec(thread)
+diff --git a/Lib/test/test_cext/setup.py b/Lib/test/test_cext/setup.py
+index 10a3887931932ac..3b613ee729f52c4 100644
+--- a/Lib/test/test_cext/setup.py
++++ b/Lib/test/test_cext/setup.py
+@@ -42,6 +42,9 @@
+ 
+         # Ask for strict(er) compliance with the standard
+         '-pedantic-errors',
++
++        # gh-154643: Headers should not use undefined macros in #if
++        '-Werror=undef',
+     ]
+     if not support.Py_GIL_DISABLED:
+         PUBLIC_CFLAGS.append(
+@@ -94,6 +97,9 @@
+ 
+         # We also use `long long`, a C++11 feature we can enable individually.
+         '-Wno-long-long',
++
++        # gh-154643: Headers should not use undefined macros in #if
++        '-Werror=undef',
+     ]
+     INTERNAL_CXXFLAGS = [
+         # Do not complain about unused parameteres in the internal C API
+diff --git a/Misc/NEWS.d/next/C_API/2026-07-24-22-30-40.gh-issue-154643.z-ZutK.rst b/Misc/NEWS.d/next/C_API/2026-07-24-22-30-40.gh-issue-154643.z-ZutK.rst
+new file mode 100644
+index 000000000000000..17c2a58555e7ae9
+--- /dev/null
++++ b/Misc/NEWS.d/next/C_API/2026-07-24-22-30-40.gh-issue-154643.z-ZutK.rst
+@@ -0,0 +1,2 @@
++In ``pyport.h`` and ``pyatomic.h`` don't use ``_Py_STDC_VERSION`` when it is
++not defined, fixing build errors for C or C++ code built with ``-Werror=undef``.
diff --git a/meta/recipes-devtools/python/python3_3.15.2.bb b/meta/recipes-devtools/python/python3_3.15.2.bb
index bfc783c922..0d1c3f05f8 100644
--- a/meta/recipes-devtools/python/python3_3.15.2.bb
+++ b/meta/recipes-devtools/python/python3_3.15.2.bb
@@ -24,6 +24,7 @@  SRC_URI = "http://www.python.org/ftp/python/${PV}/Python-${PV}.tar.xz \
            file://0001-3.15-gh-158097-Make-test_staggered_race_with_eager_t.patch \
            file://0001-3.15-gh-160924-Don-t-run-the-build-Python-with-RUNSH.patch \
            file://0001-gh-160881-Fix-test_is_python_process_non_python_subp.patch \
+           file://0001-3.15-gh-154643-Only-use-_Py_STDC_VERSION-when-defined.patch \
            "
 SRC_URI:append:class-native = " \
            file://0001-Lib-sysconfig.py-use-prefix-value-from-build-configu.patch \