summaryrefslogtreecommitdiffstats
path: root/Python
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-03-13 22:38:08 (GMT)
committerGitHub <noreply@github.com>2020-03-13 22:38:08 (GMT)
commit8fb02b6e1942811c8d81041e7df3f5f1f4b1d410 (patch)
tree3aa66f0f66f706d076cacd4f207039bdca5675bb /Python
parentbe79373a78c0d75fc715ab64253c9b757987a848 (diff)
downloadcpython-8fb02b6e1942811c8d81041e7df3f5f1f4b1d410.zip
cpython-8fb02b6e1942811c8d81041e7df3f5f1f4b1d410.tar.gz
cpython-8fb02b6e1942811c8d81041e7df3f5f1f4b1d410.tar.bz2
bpo-39947: Add PyThreadState_GetInterpreter() (GH-18981)
Add PyThreadState_GetInterpreter(tstate): get the interpreter of a Python thread state.
Diffstat (limited to 'Python')
-rw-r--r--Python/pystate.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Python/pystate.c b/Python/pystate.c
index 28c5578..f92c2b4 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -998,6 +998,17 @@ PyThreadState_GetDict(void)
}
+PyInterpreterState *
+PyThreadState_GetInterpreter(PyThreadState *tstate)
+{
+ assert(tstate != NULL);
+ if (tstate == NULL) {
+ return NULL;
+ }
+ return tstate->interp;
+}
+
+
/* Asynchronously raise an exception in a thread.
Requested by Just van Rossum and Alex Martelli.
To prevent naive misuse, you must write your own extension