bpo-39947: Add PyThreadState_GetInterpreter() (GH-18981)

Add PyThreadState_GetInterpreter(tstate): get the interpreter of a
Python thread state.
This commit is contained in:
Victor Stinner 2020-03-13 23:38:08 +01:00 committed by GitHub
parent be79373a78
commit 8fb02b6e19
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 9 deletions

View file

@ -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