Skip to content

Commit

Permalink
[3.13] pythongh-127865: Fix build failure for systems without thread …
Browse files Browse the repository at this point in the history
…local support (pythonGH-127866) (pythonGH-127882)

This PR fixes the build issue introduced by the commit 628f6eb from
pythonGH-112207 on systems without thread local support.
(cherry picked from commit f823910)

Co-authored-by: velemas <[email protected]>
  • Loading branch information
miss-islington and velemas authored Dec 12, 2024
1 parent d51c144 commit f21b38c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix build failure on systems without thread-locals support.
8 changes: 4 additions & 4 deletions Python/import.c
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,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, '.');
Expand All @@ -757,7 +757,7 @@ _PyImport_ResolveNameWithPackageContext(const char *name)
}
}
#ifndef HAVE_THREAD_LOCAL
PyThread_release_lock(EXTENSIONS.mutex);
PyMutex_Unlock(&EXTENSIONS.mutex);
#endif
return name;
}
Expand All @@ -766,12 +766,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;
}
Expand Down

0 comments on commit f21b38c

Please sign in to comment.