From 8fb02b6e1942811c8d81041e7df3f5f1f4b1d410 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 13 Mar 2020 23:38:08 +0100 Subject: bpo-39947: Add PyThreadState_GetInterpreter() (GH-18981) Add PyThreadState_GetInterpreter(tstate): get the interpreter of a Python thread state. --- Python/pystate.c | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'Python/pystate.c') diff --git a/Python/pystate.c b/Python/pystate.c index 28c5578664..f92c2b4c5e 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 -- cgit v1.2.1