mirror of
https://github.com/python/cpython.git
synced 2025-08-04 08:59:19 +00:00
bpo-43268: Pass interp rather than tstate to internal functions (GH-24580)
Pass the current interpreter (interp) rather than the current Python thread state (tstate) to internal functions which only use the interpreter. Modified functions: * _PyXXX_Fini() and _PyXXX_ClearFreeList() functions * _PyEval_SignalAsyncExc(), make_pending_calls() * _PySys_GetObject(), sys_set_object(), sys_set_object_id(), sys_set_object_str() * should_audit(), set_flags_from_config(), make_flags() * _PyAtExit_Call() * init_stdio_encoding() * etc.
This commit is contained in:
parent
a486054b24
commit
bcb094b41f
29 changed files with 240 additions and 245 deletions
|
@ -301,16 +301,16 @@ _PyImport_GetModuleId(struct _Py_Identifier *nameid)
|
|||
int
|
||||
_PyImport_SetModule(PyObject *name, PyObject *m)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
PyObject *modules = tstate->interp->modules;
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
PyObject *modules = interp->modules;
|
||||
return PyObject_SetItem(modules, name, m);
|
||||
}
|
||||
|
||||
int
|
||||
_PyImport_SetModuleString(const char *name, PyObject *m)
|
||||
{
|
||||
PyThreadState *tstate = _PyThreadState_GET();
|
||||
PyObject *modules = tstate->interp->modules;
|
||||
PyInterpreterState *interp = _PyInterpreterState_GET();
|
||||
PyObject *modules = interp->modules;
|
||||
return PyMapping_SetItemString(modules, name, m);
|
||||
}
|
||||
|
||||
|
@ -342,9 +342,8 @@ import_get_module(PyThreadState *tstate, PyObject *name)
|
|||
|
||||
|
||||
static int
|
||||
import_ensure_initialized(PyThreadState *tstate, PyObject *mod, PyObject *name)
|
||||
import_ensure_initialized(PyInterpreterState *interp, PyObject *mod, PyObject *name)
|
||||
{
|
||||
PyInterpreterState *interp = tstate->interp;
|
||||
PyObject *spec;
|
||||
|
||||
_Py_IDENTIFIER(_lock_unlock_module);
|
||||
|
@ -1530,7 +1529,7 @@ PyImport_GetModule(PyObject *name)
|
|||
|
||||
mod = import_get_module(tstate, name);
|
||||
if (mod != NULL && mod != Py_None) {
|
||||
if (import_ensure_initialized(tstate, mod, name) < 0) {
|
||||
if (import_ensure_initialized(tstate->interp, mod, name) < 0) {
|
||||
Py_DECREF(mod);
|
||||
remove_importlib_frames(tstate);
|
||||
return NULL;
|
||||
|
@ -1594,7 +1593,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
|
|||
}
|
||||
|
||||
if (mod != NULL && mod != Py_None) {
|
||||
if (import_ensure_initialized(tstate, mod, name) < 0) {
|
||||
if (import_ensure_initialized(tstate->interp, mod, name) < 0) {
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue