Skip to content

gh-160719: Define _Py_STDC_VERSION in pyport.h - #160733

Open
skdas20 wants to merge 1 commit into
python:mainfrom
skdas20:gh-160719-stdc-version
Open

skdas20 wants to merge 1 commit into
python:mainfrom
skdas20:gh-160719-stdc-version

Conversation

@skdas20

@skdas20 skdas20 commented Oct 26, 2026

Copy link
Copy Markdown

pyport.h uses _Py_STDC_VERSION to pick _Py_thread_local, _Py_NULL and _Py_TYPEOF, but the macro is defined in pymacro.h, which Python.h includes after pyport.h. So those C11/C23 branches are never taken. This moves the definition into pyport.h.

Macro values with #include "Python.h" (cc -E -dM):

Compiler Macro Before After
gcc 13, -std=c11 _Py_thread_local __thread _Thread_local
clang 18, -std=c23 _Py_NULL NULL nullptr
clang 18, -std=c23 _Py_TYPEOF(expr) __typeof__(expr) typeof(expr)

./python -m test test_cext -u cpu passes on Linux (the MSVC-only test is skipped).

This doesn't touch the inverted static_assert fallback condition in pymacro.h, which gh-160705 already fixes.

🤖 Generated with Claude Code

pyport.h uses _Py_STDC_VERSION to select _Py_thread_local, _Py_NULL and
_Py_TYPEOF, but the macro was defined in pymacro.h, which Python.h
includes after pyport.h. The C11 and C23 branches were therefore never
taken. Move the definition to pyport.h.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@NotorandXor256

NotorandXor256 commented Oct 27, 2026 •

Copy link
Copy Markdown

hello @skdas20, can i help with unsuccessful test
I am a first time contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants