mirror of
https://github.com/python/cpython.git
synced 2025-12-08 06:10:17 +00:00
Merge remote-tracking branch 'origin/main' into HEAD
This commit is contained in:
commit
8d57aca95a
1284 changed files with 27792 additions and 11927 deletions
|
|
@ -797,18 +797,13 @@ _PyImport_ClearModulesByIndex(PyInterpreterState *interp)
|
|||
substitute this (if the name actually matches).
|
||||
*/
|
||||
|
||||
#ifdef HAVE_THREAD_LOCAL
|
||||
_Py_thread_local const char *pkgcontext = NULL;
|
||||
# undef PKGCONTEXT
|
||||
# define PKGCONTEXT pkgcontext
|
||||
#endif
|
||||
|
||||
const char *
|
||||
_PyImport_ResolveNameWithPackageContext(const char *name)
|
||||
{
|
||||
#ifndef HAVE_THREAD_LOCAL
|
||||
PyMutex_Lock(&EXTENSIONS.mutex);
|
||||
#endif
|
||||
if (PKGCONTEXT != NULL) {
|
||||
const char *p = strrchr(PKGCONTEXT, '.');
|
||||
if (p != NULL && strcmp(name, p+1) == 0) {
|
||||
|
|
@ -816,23 +811,14 @@ _PyImport_ResolveNameWithPackageContext(const char *name)
|
|||
PKGCONTEXT = NULL;
|
||||
}
|
||||
}
|
||||
#ifndef HAVE_THREAD_LOCAL
|
||||
PyMutex_Unlock(&EXTENSIONS.mutex);
|
||||
#endif
|
||||
return name;
|
||||
}
|
||||
|
||||
const char *
|
||||
_PyImport_SwapPackageContext(const char *newcontext)
|
||||
{
|
||||
#ifndef HAVE_THREAD_LOCAL
|
||||
PyMutex_Lock(&EXTENSIONS.mutex);
|
||||
#endif
|
||||
const char *oldcontext = PKGCONTEXT;
|
||||
PKGCONTEXT = newcontext;
|
||||
#ifndef HAVE_THREAD_LOCAL
|
||||
PyMutex_Unlock(&EXTENSIONS.mutex);
|
||||
#endif
|
||||
return oldcontext;
|
||||
}
|
||||
|
||||
|
|
@ -2373,6 +2359,7 @@ create_builtin(PyThreadState *tstate, PyObject *name, PyObject *spec)
|
|||
for (struct _inittab *p = INITTAB; p->name != NULL; p++) {
|
||||
if (_PyUnicode_EqualToASCIIString(info.name, p->name)) {
|
||||
found = p;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (found == NULL) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue