File tree 1 file changed +15
-0
lines changed
1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -703,28 +703,43 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp)
703
703
_PyRuntime.imports.pkgcontext, and PyModule_Create*() will
704
704
substitute this (if the name actually matches).
705
705
*/
706
+
707
+ #ifdef HAVE_THREAD_LOCAL
708
+ _Py_thread_local const char * pkgcontext = NULL ;
709
+ # undef PKGCONTEXT
710
+ # define PKGCONTEXT pkgcontext
711
+ #endif
712
+
706
713
const char *
707
714
_PyImport_ResolveNameWithPackageContext (const char * name )
708
715
{
716
+ #ifndef HAVE_THREAD_LOCAL
709
717
PyThread_acquire_lock (EXTENSIONS .mutex , WAIT_LOCK );
718
+ #endif
710
719
if (PKGCONTEXT != NULL) {
711
720
const char * p = strrchr (PKGCONTEXT , '.' );
712
721
if (p != NULL && strcmp (name , p + 1 ) == 0 ) {
713
722
name = PKGCONTEXT ;
714
723
PKGCONTEXT = NULL ;
715
724
}
716
725
}
726
+ #ifndef HAVE_THREAD_LOCAL
717
727
PyThread_release_lock (EXTENSIONS .mutex );
728
+ #endif
718
729
return name ;
719
730
}
720
731
721
732
const char *
722
733
_PyImport_SwapPackageContext (const char * newcontext )
723
734
{
735
+ #ifndef HAVE_THREAD_LOCAL
724
736
PyThread_acquire_lock (EXTENSIONS .mutex , WAIT_LOCK );
737
+ #endif
725
738
const char * oldcontext = PKGCONTEXT ;
726
739
PKGCONTEXT = newcontext ;
740
+ #ifndef HAVE_THREAD_LOCAL
727
741
PyThread_release_lock (EXTENSIONS .mutex );
742
+ #endif
728
743
return oldcontext ;
729
744
}
730
745
You can’t perform that action at this time.
0 commit comments