Repository navigation
Conversation
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>
|
hello @skdas20, can i help with unsuccessful test |
| #if !defined(__cplusplus) && defined(__STDC_VERSION__) | ||
| # define _Py_STDC_VERSION __STDC_VERSION__ | ||
| #endif | ||
| // _Py_STDC_VERSION is defined in pyport.h, which is included before this file. |
There was a problem hiding this comment.
I don't tink that this comment is useful. We don't do it for other macros. I suggest removing it.
| private ``_Py_STDC_VERSION`` macro was defined in :file:`pymacro.h`, which is | ||
| included after :file:`pyport.h`, so ``_Py_thread_local``, ``_Py_NULL`` and | ||
| ``_Py_TYPEOF`` fell back to compiler extensions instead of ``_Thread_local``, | ||
| ``nullptr`` and ``typeof``. |
There was a problem hiding this comment.
I'm not sure that it's useful to end users to know about the fix. It's not a big deal to use another implementation if C23 detection was broken. I suggest removing the Changelog entry.
Note: Sadly, the _Py_STDC_VERSION change landed in Python 3.15.2 release.
| // gh-160719: Defined here, rather than in pymacro.h, because this file uses it | ||
| // and is included before pymacro.h. |
There was a problem hiding this comment.
I don't think that this remark/note is useful.
|
The following commit authors need to sign the Contributor License Agreement: |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
Thanks @vstinner, done: I removed the extra comments and the NEWS entry. The change is now just moving the |
|
Most changes to Python require a NEWS entry. Add one using the blurb_it web app or the blurb command-line tool. If this change has little impact on Python users, wait for a maintainer to apply the |
|
@skdas20: Would you mind to sign the Python CLA? See #160733 (comment) comment for details. |
pyport.huses_Py_STDC_VERSIONto pick_Py_thread_local,_Py_NULLand_Py_TYPEOF, but the macro is defined inpymacro.h, whichPython.hincludes afterpyport.h. So those C11/C23 branches are never taken. This moves the definition intopyport.h.Macro values with
#include "Python.h"(cc -E -dM):-std=c11_Py_thread_local__thread_Thread_local-std=c23_Py_NULLNULLnullptr-std=c23_Py_TYPEOF(expr)__typeof__(expr)typeof(expr)./python -m test test_cext -u cpupasses on Linux (the MSVC-only test is skipped).This doesn't touch the inverted
static_assertfallback condition inpymacro.h, which gh-160705 already fixes._Py_STDC_VERSIONmacro not available in pyport.h #160719🤖 Generated with Claude Code