Skip to content

Commit 4172885

Browse files
gh-142163: Only define HAVE_THREAD_LOCAL when Py_BUILD_CORE is set (#142164)
1 parent eb89286 commit 4172885

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

Include/pyport.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -509,9 +509,15 @@ extern "C" {
509509
# define Py_CAN_START_THREADS 1
510510
#endif
511511

512-
#ifdef WITH_THREAD
513-
// HAVE_THREAD_LOCAL is just defined here for compatibility's sake
512+
513+
/* gh-142163: Some libraries rely on HAVE_THREAD_LOCAL being undefined, so
514+
* we can only define it only when Py_BUILD_CORE is set.*/
515+
#ifdef Py_BUILD_CORE
516+
// This is no longer coupled to _Py_thread_local.
514517
# define HAVE_THREAD_LOCAL 1
518+
#endif
519+
520+
#ifdef WITH_THREAD
515521
# ifdef thread_local
516522
# define _Py_thread_local thread_local
517523
# elif __STDC_VERSION__ >= 201112L && !defined(__STDC_NO_THREADS__)
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Fix the ``HAVE_THREAD_LOCAL`` macro being defined without the
2+
``Py_BUILD_CORE`` macro set after including :file:`Python.h`.

0 commit comments

Comments
 (0)