bpo-34301: Add _PyInterpreterState_Get() helper function (GH-8592)

sys_setcheckinterval() now uses a local variable to parse arguments,
before writing into interp->check_interval.
This commit is contained in:
Victor Stinner 2018-08-03 15:33:52 +02:00 committed by GitHub
parent 2ebd3813af
commit caba55b3b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
22 changed files with 107 additions and 93 deletions

View file

@ -304,7 +304,7 @@ _PyImport_Fini2(void)
PyObject *
PyImport_GetModuleDict(void)
{
PyInterpreterState *interp = PyThreadState_GET()->interp;
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
if (interp->modules == NULL) {
Py_FatalError("PyImport_GetModuleDict: no module dictionary!");
}
@ -397,7 +397,7 @@ PyImport_Cleanup(void)
{
Py_ssize_t pos;
PyObject *key, *value, *dict;
PyInterpreterState *interp = PyThreadState_GET()->interp;
PyInterpreterState *interp = _PyInterpreterState_Get();
PyObject *modules = PyImport_GetModuleDict();
PyObject *weaklist = NULL;
const char * const *p;
@ -592,7 +592,7 @@ long
PyImport_GetMagicNumber(void)
{
long res;
PyInterpreterState *interp = PyThreadState_Get()->interp;
PyInterpreterState *interp = _PyInterpreterState_Get();
PyObject *external, *pyc_magic;
external = PyObject_GetAttrString(interp->importlib, "_bootstrap_external");
@ -892,7 +892,7 @@ PyImport_ExecCodeModuleWithPathnames(const char *name, PyObject *co,
goto error;
}
else if (cpathobj != NULL) {
PyInterpreterState *interp = PyThreadState_GET()->interp;
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
_Py_IDENTIFIER(_get_sourcefile);
if (interp == NULL) {
@ -972,7 +972,7 @@ PyImport_ExecCodeModuleObject(PyObject *name, PyObject *co, PyObject *pathname,
PyObject *cpathname)
{
PyObject *d, *external, *res;
PyInterpreterState *interp = PyThreadState_GET()->interp;
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
_Py_IDENTIFIER(_fix_up_module);
d = module_dict_for_exec(name);
@ -1619,7 +1619,7 @@ import_find_and_load(PyObject *abs_name)
{
_Py_IDENTIFIER(_find_and_load);
PyObject *mod = NULL;
PyInterpreterState *interp = PyThreadState_GET()->interp;
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
int import_time = interp->core_config.import_time;
static int import_level;
static _PyTime_t accumulated;
@ -1680,7 +1680,7 @@ PyImport_ImportModuleLevelObject(PyObject *name, PyObject *globals,
PyObject *final_mod = NULL;
PyObject *mod = NULL;
PyObject *package = NULL;
PyInterpreterState *interp = PyThreadState_GET()->interp;
PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
int has_from;
if (name == NULL) {
@ -2289,7 +2289,7 @@ PyInit__imp(void)
d = PyModule_GetDict(m);
if (d == NULL)
goto failure;
_PyCoreConfig *config = &PyThreadState_GET()->interp->core_config;
_PyCoreConfig *config = &_PyInterpreterState_Get()->core_config;
PyObject *pyc_mode = PyUnicode_FromString(config->_check_hash_pycs_mode);
if (pyc_mode == NULL) {
goto failure;