bpo-40268: Rename _PyInterpreterState_GET_UNSAFE() (GH-19509)
Rename _PyInterpreterState_GET_UNSAFE() to _PyInterpreterState_GET()
for consistency with _PyThreadState_GET() and to have a shorter name
(help to fit into 80 columns).
Add also "assert(tstate != NULL);" to the function.
diff --git a/Include/cpython/pystate.h b/Include/cpython/pystate.h
index 7052228..9b28f66 100644
--- a/Include/cpython/pystate.h
+++ b/Include/cpython/pystate.h
@@ -165,7 +165,7 @@
This function doesn't check for error. Return NULL before _PyGILState_Init()
is called and after _PyGILState_Fini() is called.
- See also _PyInterpreterState_Get() and _PyInterpreterState_GET_UNSAFE(). */
+ See also _PyInterpreterState_Get() and _PyInterpreterState_GET(). */
PyAPI_FUNC(PyInterpreterState *) _PyGILState_GetInterpreterStateUnsafe(void);
/* The implementation of sys._current_frames() Returns a dict mapping
diff --git a/Include/internal/pycore_pystate.h b/Include/internal/pycore_pystate.h
index 2e78378..c82e8db 100644
--- a/Include/internal/pycore_pystate.h
+++ b/Include/internal/pycore_pystate.h
@@ -78,8 +78,9 @@
See also _PyInterpreterState_Get()
and _PyGILState_GetInterpreterStateUnsafe(). */
-static inline PyInterpreterState* _PyInterpreterState_GET_UNSAFE(void) {
+static inline PyInterpreterState* _PyInterpreterState_GET(void) {
PyThreadState *tstate = _PyThreadState_GET();
+ assert(tstate != NULL);
return tstate->interp;
}