summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2018-08-03 13:33:52 (GMT)
committerGitHub <noreply@github.com>2018-08-03 13:33:52 (GMT)
commitcaba55b3b735405b280273f7d99866a046c18281 (patch)
tree3a98ac383b1fbab272158933255fb1a14107ebf6 /Modules
parent2ebd3813af9172fe1f9b2f6004edf6f1e1e5d9f1 (diff)
downloadcpython-caba55b3b735405b280273f7d99866a046c18281.zip
cpython-caba55b3b735405b280273f7d99866a046c18281.tar.gz
cpython-caba55b3b735405b280273f7d99866a046c18281.tar.bz2
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.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_threadmodule.c10
-rw-r--r--Modules/_xxsubinterpretersmodule.c7
-rw-r--r--Modules/posixmodule.c8
-rw-r--r--Modules/zipimport.c4
4 files changed, 14 insertions, 15 deletions
diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c
index 69e27be..f6b39de 100644
--- a/Modules/_threadmodule.c
+++ b/Modules/_threadmodule.c
@@ -1049,7 +1049,7 @@ thread_PyThread_start_new_thread(PyObject *self, PyObject *fargs)
boot = PyMem_NEW(struct bootstate, 1);
if (boot == NULL)
return PyErr_NoMemory();
- boot->interp = PyThreadState_GET()->interp;
+ boot->interp = _PyInterpreterState_Get();
boot->func = func;
boot->args = args;
boot->keyw = keyw;
@@ -1154,8 +1154,8 @@ A thread's identity may be reused for another thread after it exits.");
static PyObject *
thread__count(PyObject *self, PyObject *Py_UNUSED(ignored))
{
- PyThreadState *tstate = PyThreadState_Get();
- return PyLong_FromLong(tstate->interp->num_threads);
+ PyInterpreterState *interp = _PyInterpreterState_Get();
+ return PyLong_FromLong(interp->num_threads);
}
PyDoc_STRVAR(_count_doc,
@@ -1348,7 +1348,7 @@ PyInit__thread(void)
PyObject *m, *d, *v;
double time_max;
double timeout_max;
- PyThreadState *tstate = PyThreadState_Get();
+ PyInterpreterState *interp = _PyInterpreterState_Get();
/* Initialize types: */
if (PyType_Ready(&localdummytype) < 0)
@@ -1395,7 +1395,7 @@ PyInit__thread(void)
if (PyModule_AddObject(m, "_local", (PyObject *)&localtype) < 0)
return NULL;
- tstate->interp->num_threads = 0;
+ interp->num_threads = 0;
str_dict = PyUnicode_InternFromString("__dict__");
if (str_dict == NULL)
diff --git a/Modules/_xxsubinterpretersmodule.c b/Modules/_xxsubinterpretersmodule.c
index 8567e4f..6162c53 100644
--- a/Modules/_xxsubinterpretersmodule.c
+++ b/Modules/_xxsubinterpretersmodule.c
@@ -26,10 +26,9 @@ _copy_raw_string(PyObject *strobj)
static PyInterpreterState *
_get_current(void)
{
- PyThreadState *tstate = PyThreadState_Get();
- // PyThreadState_Get() aborts if lookup fails, so we don't need
+ // _PyInterpreterState_Get() aborts if lookup fails, so don't need
// to check the result for NULL.
- return tstate->interp;
+ return _PyInterpreterState_Get();
}
static int64_t
@@ -1941,7 +1940,7 @@ _run_script_in_interpreter(PyInterpreterState *interp, const char *codestr,
// Switch to interpreter.
PyThreadState *save_tstate = NULL;
- if (interp != PyThreadState_Get()->interp) {
+ if (interp != _PyInterpreterState_Get()) {
// XXX Using the "head" thread isn't strictly correct.
PyThreadState *tstate = PyInterpreterState_ThreadHead(interp);
// XXX Possible GILState issues?
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
index 6104c0f..3e03039 100644
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -437,7 +437,7 @@ run_at_forkers(PyObject *lst, int reverse)
void
PyOS_BeforeFork(void)
{
- run_at_forkers(PyThreadState_Get()->interp->before_forkers, 1);
+ run_at_forkers(_PyInterpreterState_Get()->before_forkers, 1);
_PyImport_AcquireLock();
}
@@ -448,7 +448,7 @@ PyOS_AfterFork_Parent(void)
if (_PyImport_ReleaseLock() <= 0)
Py_FatalError("failed releasing import lock after fork");
- run_at_forkers(PyThreadState_Get()->interp->after_forkers_parent, 0);
+ run_at_forkers(_PyInterpreterState_Get()->after_forkers_parent, 0);
}
void
@@ -459,7 +459,7 @@ PyOS_AfterFork_Child(void)
_PyImport_ReInitLock();
_PySignal_AfterFork();
- run_at_forkers(PyThreadState_Get()->interp->after_forkers_child, 0);
+ run_at_forkers(_PyInterpreterState_Get()->after_forkers_child, 0);
}
static int
@@ -5655,7 +5655,7 @@ os_register_at_fork_impl(PyObject *module, PyObject *before,
check_null_or_callable(after_in_parent, "after_in_parent")) {
return NULL;
}
- interp = PyThreadState_Get()->interp;
+ interp = _PyInterpreterState_Get();
if (register_at_forker(&interp->before_forkers, before)) {
return NULL;
diff --git a/Modules/zipimport.c b/Modules/zipimport.c
index 57e7a13..4df4ba9 100644
--- a/Modules/zipimport.c
+++ b/Modules/zipimport.c
@@ -1074,7 +1074,7 @@ read_directory(PyObject *archive)
if (flags & 0x0800) {
charset = "utf-8";
}
- else if (!PyThreadState_GET()->interp->codecs_initialized) {
+ else if (!_PyInterpreterState_Get()->codecs_initialized) {
/* During bootstrap, we may need to load the encodings
package from a ZIP file. But the cp437 encoding is implemented
in Python in the encodings package.
@@ -1351,7 +1351,7 @@ unmarshal_code(PyObject *pathname, PyObject *data, time_t mtime)
uint32_t flags = get_uint32(buf + 4);
if (flags != 0) {
- _PyCoreConfig *config = &PyThreadState_GET()->interp->core_config;
+ _PyCoreConfig *config = &_PyInterpreterState_Get()->core_config;
// Hash-based pyc. We currently refuse to handle checked hash-based
// pycs. We could validate hash-based pycs against the source, but it
// seems likely that most people putting hash-based pycs in a zipfile