10000 Add check_multi_interp_extensions(). · python/cpython@3c084eb · GitHub
[go: up one dir, main page]

Skip to content

Commit 3c084eb

Browse files
Add check_multi_interp_extensions().
1 parent 9c24b34 commit 3c084eb

File tree

1 file changed

+18
-4
lines changed

1 file changed

+18
-4
lines changed

Python/import.c

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2395,14 +2395,28 @@ exec_builtin_or_dynamic(PyObject *mod) {
23952395
return PyModule_ExecDef(mod, def);
23962396
}
23972397

2398+
static bool
2399+
check_multi_interp_extensions(PyInterpreterState *interp)
2400+
{
2401+
int override = interp->override_multi_interp_extensions_check;
2402+
if (override < 0) {
2403+
return false;
2404+
}
2405+
else if (override > 0) {
2406+
return true;
2407+
}
2408+
else if (_PyInterpreterState_HasFeature(
2409+
interp, Py_RTFLAGS_MULTI_INTERP_EXTENSIONS)) {
2410+
return true;
2411+
}
2412+
return false;
2413+
}
2414+
23982415
int
23992416
_PyImport_CheckSubinterpIncompatibleExtensionAllowed(const char *name)
24002417
{
24012418
PyInterpreterState *interp = _PyInterpreterState_Get();
2402-
if (_PyInterpreterState_HasFeature(
2403-
interp, Py_RTFLAGS_MULTI_INTERP_EXTENSIONS) &&
2404-
!interp->override_multi_interp_extensions_check
2405-
) {
2419+
if (check_multi_interp_extensions(interp)) {
24062420
assert(!_Py_IsMainInterpreter(interp));
24072421
PyErr_Format(PyExc_ImportError,
24082422
"module %s does not support loading in subinterpreters",

0 commit comments

Comments
 (0)
0