https://github.com/python/cpython/commit/41728856a277749d022d99af82c8e14b85057f3c
commit: 41728856a277749d022d99af82c8e14b85057f3c
branch: main
author: Peter Bierma <[email protected]>
committer: kumaraditya303 <[email protected]>
date: 2025-12-02T09:43:11+05:30
summary:

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

files:
A Misc/NEWS.d/next/C_API/2025-12-01-18-17-16.gh-issue-142163.2HiX5A.rst
M Include/pyport.h

diff --git a/Include/pyport.h b/Include/pyport.h
index 97c0e195d19808..61e2317976eed1 100644
--- a/Include/pyport.h
+++ b/Include/pyport.h
@@ -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__)
diff --git 
a/Misc/NEWS.d/next/C_API/2025-12-01-18-17-16.gh-issue-142163.2HiX5A.rst 
b/Misc/NEWS.d/next/C_API/2025-12-01-18-17-16.gh-issue-142163.2HiX5A.rst
new file mode 100644
index 00000000000000..5edcfd81992c13
--- /dev/null
+++ b/Misc/NEWS.d/next/C_API/2025-12-01-18-17-16.gh-issue-142163.2HiX5A.rst
@@ -0,0 +1,2 @@
+Fix the ``HAVE_THREAD_LOCAL`` macro being defined without the
+``Py_BUILD_CORE`` macro set after including :file:`Python.h`.

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to