summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-11-20 16:34:39 (GMT)
committerGitHub <noreply@github.com>2019-11-20 16:34:39 (GMT)
commitfff7bbfdb6b7c143b73b6b4b6b40e828c101110c (patch)
tree36493fb3f956d9c5867b7312a0916c38956d0e13 /Python
parentdb7925a1cac361ad8c94123a38b00b70f306c48d (diff)
downloadcpython-fff7bbfdb6b7c143b73b6b4b6b40e828c101110c.zip
cpython-fff7bbfdb6b7c143b73b6b4b6b40e828c101110c.tar.gz
cpython-fff7bbfdb6b7c143b73b6b4b6b40e828c101110c.tar.bz2
bpo-38858: Add _Py_IsMainInterpreter(tstate) (GH-17293)
Diffstat (limited to 'Python')
-rw-r--r--Python/pystate.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 2fc563b..0a6d035 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -159,6 +159,12 @@ _PyRuntimeState_ReInitThreads(_PyRuntimeState *runtime)
#define HEAD_UNLOCK(runtime) \
PyThread_release_lock((runtime)->interpreters.mutex)
+int
+_Py_IsMainInterpreter(PyThreadState* tstate)
+{
+ return (tstate->interp == tstate->interp->runtime->interpreters.main);
+}
+
/* Forward declaration */
static void _PyGILState_NoteThreadState(
struct _gilstate_runtime_state *gilstate, PyThreadState* tstate);