summaryrefslogtreecommitdiffstats
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-13 17:03:56 (GMT)
committerGitHub <noreply@github.com>2020-03-13 17:03:56 (GMT)
commitff4584caca04cb3da0dbd5b1e9bf67e40adf5312 (patch)
treefedb1e89a042baedb4475e76b12fcf79e2f77837 /Python/pythonrun.c
parent6d674a1bf456945eb758e85c11484a9f1494f2b4 (diff)
downloadcpython-ff4584caca04cb3da0dbd5b1e9bf67e40adf5312.zip
cpython-ff4584caca04cb3da0dbd5b1e9bf67e40adf5312.tar.gz
cpython-ff4584caca04cb3da0dbd5b1e9bf67e40adf5312.tar.bz2
bpo-39947: Use _PyInterpreterState_GET_UNSAFE() (GH-18978)
Replace _PyInterpreterState_Get() function call with _PyInterpreterState_GET_UNSAFE() macro which is more efficient but don't check if tstate or interp is NULL. _Py_GetConfigsAsDict() now uses _PyThreadState_GET().
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index f4ded2e..76bc48d 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -95,7 +95,7 @@ PyRun_InteractiveLoopFlags(FILE *fp, const char *filename_str, PyCompilerFlags *
PyCompilerFlags local_flags = _PyCompilerFlags_INIT;
int nomem_count = 0;
#ifdef Py_REF_DEBUG
- int show_ref_count = _PyInterpreterState_Get()->config.show_ref_count;
+ int show_ref_count = _PyInterpreterState_GET_UNSAFE()->config.show_ref_count;
#endif
filename = PyUnicode_DecodeFSDefault(filename_str);
@@ -346,7 +346,7 @@ set_main_loader(PyObject *d, const char *filename, const char *loader_name)
filename_obj = PyUnicode_DecodeFSDefault(filename);
if (filename_obj == NULL)
return -1;
- PyInterpreterState *interp = _PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
bootstrap = PyObject_GetAttrString(interp->importlib,
"_bootstrap_external");
if (bootstrap != NULL) {
@@ -1117,7 +1117,7 @@ run_eval_code_obj(PyCodeObject *co, PyObject *globals, PyObject *locals)
/* Set globals['__builtins__'] if it doesn't exist */
if (globals != NULL && PyDict_GetItemString(globals, "__builtins__") == NULL) {
- PyInterpreterState *interp = _PyInterpreterState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_GET_UNSAFE();
if (PyDict_SetItemString(globals, "__builtins__", interp->builtins) < 0) {
return NULL;
}