diff options
author | Victor Stinner <vstinner@python.org> | 2020-04-13 01:04:28 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-13 01:04:28 (GMT) |
commit | da7933ecc30e37b119756cb02b89a6ad99db22e0 (patch) | |
tree | e6c7227f2ded7b7354fb027342fa977f70808d10 /Python/pylifecycle.c | |
parent | 14d5331eb5e6c38be12bad421bd59ad0fac9e448 (diff) | |
download | cpython-da7933ecc30e37b119756cb02b89a6ad99db22e0.zip cpython-da7933ecc30e37b119756cb02b89a6ad99db22e0.tar.gz cpython-da7933ecc30e37b119756cb02b89a6ad99db22e0.tar.bz2 |
bpo-40268: Add _PyInterpreterState_GetConfig() (GH-19492)
Don't access PyInterpreterState.config member directly anymore, but
use new functions:
* _PyInterpreterState_GetConfig()
* _PyInterpreterState_SetConfig()
* _Py_GetConfig()
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 9b413c6..1bc7d77 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -157,7 +157,7 @@ init_importlib(PyThreadState *tstate, PyObject *sysmod) PyObject *impmod; PyObject *value; PyInterpreterState *interp = tstate->interp; - int verbose = interp->config.verbose; + int verbose = _PyInterpreterState_GetConfig(interp)->verbose; /* Import _importlib through its frozen version, _frozen_importlib. */ if (PyImport_ImportFrozenModule("_frozen_importlib") <= 0) { @@ -473,11 +473,11 @@ pyinit_core_reconfigure(_PyRuntimeState *runtime, _PyConfig_Write(config, runtime); - status = _PyConfig_Copy(&interp->config, config); + status = _PyInterpreterState_SetConfig(interp, config); if (_PyStatus_EXCEPTION(status)) { return status; } - config = &interp->config; + config = _PyInterpreterState_GetConfig(interp); if (config->_install_importlib) { status = _PyConfig_WritePathConfig(config); @@ -558,7 +558,7 @@ pycore_create_interpreter(_PyRuntimeState *runtime, return _PyStatus_ERR("can't make main interpreter"); } - PyStatus status = _PyConfig_Copy(&interp->config, config); + PyStatus status = _PyInterpreterState_SetConfig(interp, config); if (_PyStatus_EXCEPTION(status)) { return status; } @@ -692,7 +692,7 @@ pycore_init_import_warnings(PyThreadState *tstate, PyObject *sysmod) return status; } - const PyConfig *config = &tstate->interp->config; + const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp); if (_Py_IsMainInterpreter(tstate)) { /* Initialize _warnings. */ status = _PyWarnings_InitState(tstate); @@ -953,7 +953,7 @@ done: static PyStatus _Py_ReconfigureMainInterpreter(PyThreadState *tstate) { - PyConfig *config = &tstate->interp->config; + const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp); PyObject *argv = _PyWideStringList_AsList(&config->argv); if (argv == NULL) { @@ -977,7 +977,7 @@ init_interp_main(PyThreadState *tstate) PyStatus status; int is_main_interp = _Py_IsMainInterpreter(tstate); PyInterpreterState *interp = tstate->interp; - PyConfig *config = &interp->config; + const PyConfig *config = _PyInterpreterState_GetConfig(interp); if (!config->_install_importlib) { /* Special mode for freeze_importlib: run with no import system @@ -1146,7 +1146,7 @@ Py_InitializeFromConfig(const PyConfig *config) if (_PyStatus_EXCEPTION(status)) { return status; } - config = &tstate->interp->config; + config = _PyInterpreterState_GetConfig(tstate->interp); if (config->_init_main) { status = pyinit_main(tstate); @@ -1571,16 +1571,16 @@ new_interpreter(PyThreadState **tstate_p) PyThreadState *save_tstate = PyThreadState_Swap(tstate); /* Copy the current interpreter config into the new interpreter */ - PyConfig *config; + const PyConfig *config; if (save_tstate != NULL) { - config = &save_tstate->interp->config; + config = _PyInterpreterState_GetConfig(save_tstate->interp); } else { /* No current thread state, copy from the main interpreter */ PyInterpreterState *main_interp = PyInterpreterState_Main(); - config = &main_interp->config; + config = _PyInterpreterState_GetConfig(main_interp); } - status = _PyConfig_Copy(&interp->config, config); + status = _PyInterpreterState_SetConfig(interp, config); if (_PyStatus_EXCEPTION(status)) { goto error; } @@ -1953,7 +1953,7 @@ init_sys_streams(PyThreadState *tstate) int fd; PyObject * encoding_attr; PyStatus res = _PyStatus_OK(); - const PyConfig *config = &tstate->interp->config; + const PyConfig *config = _PyInterpreterState_GetConfig(tstate->interp); /* Check that stdin is not a directory Using shell redirection, you can redirect stdin to a directory, |