diff options
author | Victor Stinner <vstinner@redhat.com> | 2019-06-19 02:54:39 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-06-19 02:54:39 +0200 |
commit | 0a28f8d379544eee897979da0ce99f0b449b49dd (patch) | |
tree | 8bf54f5ac2e9c3fd7beff5f6fa529a4f2269f3fb /Python/pylifecycle.c | |
parent | 809ff1181ccc09c3b629f3d0ec66e13eaa111b2e (diff) | |
download | cpython-git-0a28f8d379544eee897979da0ce99f0b449b49dd.tar.gz |
bpo-36710: Add tstate parameter in import.c (GH-14218)
* Add 'tstate' parameter to many internal import.c functions.
* _PyImportZip_Init() now gets 'tstate' parameter rather than
'interp'.
* Add 'interp' parameter to _PyState_ClearModules() and rename it
to _PyInterpreterState_ClearModules().
* Move private _PyImport_FindBuiltin() to the internal C API; add
'tstate' parameter to it.
* Remove private _PyImport_AddModuleObject() from the C API:
use public PyImport_AddModuleObject() instead.
* Remove private _PyImport_FindExtensionObjectEx() from the C API:
use private _PyImport_FindExtensionObject() instead.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 54e8ce2b15..4a97295102 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -6,6 +6,7 @@ #undef Yield /* undefine macro conflicting with <winbase.h> */ #include "pycore_ceval.h" #include "pycore_context.h" +#include "pycore_import.h" /* _PyImport_FindBuiltin */ #include "pycore_initconfig.h" #include "pycore_fileutils.h" #include "pycore_hamt.h" @@ -197,17 +198,17 @@ init_importlib(PyInterpreterState *interp, PyObject *sysmod) } static PyStatus -init_importlib_external(PyInterpreterState *interp) +init_importlib_external(PyThreadState *tstate) { PyObject *value; - value = PyObject_CallMethod(interp->importlib, + value = PyObject_CallMethod(tstate->interp->importlib, "_install_external_importers", ""); if (value == NULL) { PyErr_Print(); return _PyStatus_ERR("external importer setup failed"); } Py_DECREF(value); - return _PyImportZip_Init(interp); + return _PyImportZip_Init(tstate); } /* Helper functions to better handle the legacy C locale @@ -924,7 +925,7 @@ pyinit_main(_PyRuntimeState *runtime, PyInterpreterState *interp) return _PyStatus_ERR("can't finish initializing sys"); } - PyStatus status = init_importlib_external(interp); + PyStatus status = init_importlib_external(tstate); if (_PyStatus_EXCEPTION(status)) { return status; } @@ -1449,7 +1450,7 @@ new_interpreter(PyThreadState **tstate_p) } interp->modules = modules; - PyObject *sysmod = _PyImport_FindBuiltin("sys", modules); + PyObject *sysmod = _PyImport_FindBuiltin(tstate, "sys"); if (sysmod != NULL) { interp->sysdict = PyModule_GetDict(sysmod); if (interp->sysdict == NULL) { @@ -1465,7 +1466,7 @@ new_interpreter(PyThreadState **tstate_p) goto handle_error; } - PyObject *bimod = _PyImport_FindBuiltin("builtins", modules); + PyObject *bimod = _PyImport_FindBuiltin(tstate, "builtins"); if (bimod != NULL) { interp->builtins = PyModule_GetDict(bimod); if (interp->builtins == NULL) @@ -1497,7 +1498,7 @@ new_interpreter(PyThreadState **tstate_p) return status; } - status = init_importlib_external(interp); + status = init_importlib_external(tstate); if (_PyStatus_EXCEPTION(status)) { return status; } |