[3.9] bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578) (GH-20618)

* bpo-40826: Add _Py_EnsureTstateNotNULL() macro (GH-20571)

Add _Py_EnsureTstateNotNULL(tstate) macro: call Py_FatalError() if
tstate is NULL, the error message contains the current function name.

(cherry picked from commit 3026cad59b87751a9215111776cac8e819458fce)

* bpo-40826: PyOS_InterruptOccurred() requires GIL (GH-20578)

PyOS_InterruptOccurred() now fails with a fatal error if it is called
with the GIL released.

(cherry picked from commit cbe129692293251e7fbcea9ff0d822824d90c140)
diff --git a/Modules/signalmodule.c b/Modules/signalmodule.c
index b3f5904..9041848 100644
--- a/Modules/signalmodule.c
+++ b/Modules/signalmodule.c
@@ -1784,7 +1784,7 @@
 int
 _PyOS_InterruptOccurred(PyThreadState *tstate)
 {
-    assert(tstate != NULL);
+    _Py_EnsureTstateNotNULL(tstate);
     if (!_Py_ThreadCanHandleSignals(tstate->interp)) {
         return 0;
     }