gh-142163: Only define HAVE_THREAD_LOCAL when Py_BUILD_CORE is set (#142164)

This commit is contained in:
Peter Bierma 2025-12-01 23:13:11 -05:00 committed by GitHub
parent eb892868b3
commit 41728856a2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 10 additions and 2 deletions

View file

@ -509,9 +509,15 @@ extern "C" {
# define Py_CAN_START_THREADS 1
#endif
#ifdef WITH_THREAD
// HAVE_THREAD_LOCAL is just defined here for compatibility's sake
/* gh-142163: Some libraries rely on HAVE_THREAD_LOCAL being undefined, so
* we can only define it only when Py_BUILD_CORE is set.*/
#ifdef Py_BUILD_CORE
// This is no longer coupled to _Py_thread_local.
# define HAVE_THREAD_LOCAL 1
#endif
#ifdef WITH_THREAD
# ifdef thread_local
# define _Py_thread_local thread_local
# elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)

View file

@ -0,0 +1,2 @@
Fix the ``HAVE_THREAD_LOCAL`` macro being defined without the
``Py_BUILD_CORE`` macro set after including :file:`Python.h`.