]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127865: Fix build failure for systems without thread local support (GH-127866)
authorvelemas <10437413+velemas@users.noreply.github.com>
Thu, 12 Dec 2024 18:07:55 +0000 (20:07 +0200)
committerGitHub <noreply@github.com>
Thu, 12 Dec 2024 18:07:55 +0000 (13:07 -0500)
This PR fixes the build issue introduced by the commit 628f6eb from
GH-112207 on systems without thread local support.

Misc/NEWS.d/next/Build/2024-12-12-17-21-45.gh-issue-127865.30GDzs.rst [new file with mode: 0644]
Python/import.c

diff --git a/Misc/NEWS.d/next/Build/2024-12-12-17-21-45.gh-issue-127865.30GDzs.rst b/Misc/NEWS.d/next/Build/2024-12-12-17-21-45.gh-issue-127865.30GDzs.rst
new file mode 100644 (file)
index 0000000..3fc1d8a
--- /dev/null
@@ -0,0 +1 @@
+Fix build failure on systems without thread-locals support.
index b3c384c27718ce6217d00a89804ce330739b7536..f3511aaf7b801010817f86cc0d9ddaa24f2d8036 100644 (file)
@@ -749,7 +749,7 @@ const char *
 _PyImport_ResolveNameWithPackageContext(const char *name)
 {
 #ifndef HAVE_THREAD_LOCAL
-    PyThread_acquire_lock(EXTENSIONS.mutex, WAIT_LOCK);
+    PyMutex_Lock(&EXTENSIONS.mutex);
 #endif
     if (PKGCONTEXT != NULL) {
         const char *p = strrchr(PKGCONTEXT, '.');
@@ -759,7 +759,7 @@ _PyImport_ResolveNameWithPackageContext(const char *name)
         }
     }
 #ifndef HAVE_THREAD_LOCAL
-    PyThread_release_lock(EXTENSIONS.mutex);
+    PyMutex_Unlock(&EXTENSIONS.mutex);
 #endif
     return name;
 }
@@ -768,12 +768,12 @@ const char *
 _PyImport_SwapPackageContext(const char *newcontext)
 {
 #ifndef HAVE_THREAD_LOCAL
-    PyThread_acquire_lock(EXTENSIONS.mutex, WAIT_LOCK);
+    PyMutex_Lock(&EXTENSIONS.mutex);
 #endif
     const char *oldcontext = PKGCONTEXT;
     PKGCONTEXT = newcontext;
 #ifndef HAVE_THREAD_LOCAL
-    PyThread_release_lock(EXTENSIONS.mutex);
+    PyMutex_Unlock(&EXTENSIONS.mutex);
 #endif
     return oldcontext;
 }