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()
This commit is contained in:
Victor Stinner 2020-04-13 03:04:28 +02:00 committed by GitHub
parent 14d5331eb5
commit da7933ecc3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
19 changed files with 90 additions and 64 deletions

View file

@ -102,7 +102,7 @@ _PyImportZip_Init(PyThreadState *tstate)
goto error;
}
int verbose = tstate->interp->config.verbose;
int verbose = _PyInterpreterState_GetConfig(tstate->interp)->verbose;
if (verbose) {
PySys_WriteStderr("# installing zipimport hook\n");
}
@ -446,7 +446,7 @@ _PyImport_Cleanup(PyThreadState *tstate)
/* XXX Perhaps these precautions are obsolete. Who knows? */
int verbose = interp->config.verbose;
int verbose = _PyInterpreterState_GetConfig(interp)->verbose;
if (verbose) {
PySys_WriteStderr("# clear builtins._\n");
}
@ -811,7 +811,7 @@ import_find_extension(PyThreadState *tstate, PyObject *name,
return NULL;
}
int verbose = tstate->interp->config.verbose;
int verbose = _PyInterpreterState_GetConfig(tstate->interp)->verbose;
if (verbose) {
PySys_FormatStderr("import %U # previously loaded (%R)\n",
name, filename);
@ -1523,7 +1523,7 @@ remove_importlib_frames(PyThreadState *tstate)
which end with a call to "_call_with_frames_removed". */
_PyErr_Fetch(tstate, &exception, &value, &base_tb);
if (!exception || tstate->interp->config.verbose) {
if (!exception || _PyInterpreterState_GetConfig(tstate->interp)->verbose) {
goto done;
}
@ -1727,7 +1727,7 @@ import_find_and_load(PyThreadState *tstate, PyObject *abs_name)
_Py_IDENTIFIER(_find_and_load);
PyObject *mod = NULL;
PyInterpreterState *interp = tstate->interp;
int import_time = interp->config.import_time;
int import_time = _PyInterpreterState_GetConfig(interp)->import_time;
static int import_level;
static _PyTime_t accumulated;
@ -2413,7 +2413,7 @@ PyInit__imp(void)
goto failure;
}
const wchar_t *mode = _PyInterpreterState_GET_UNSAFE()->config.check_hash_pycs_mode;
const wchar_t *mode = _Py_GetConfig()->check_hash_pycs_mode;
PyObject *pyc_mode = PyUnicode_FromWideChar(mode, -1);
if (pyc_mode == NULL) {
goto failure;