bpo-38733: PyErr_Occurred() caller must hold the GIL (GH-17080)

bpo-3605, bpo-38733: Optimize _PyErr_Occurred(): remove "tstate ==
NULL" test.

Py_FatalError() no longer calls PyErr_Occurred() if called without
holding the GIL. So PyErr_Occurred() no longer has to support
tstate==NULL case.

_Py_CheckFunctionResult(): use directly _PyErr_Occurred() to avoid
explicit "!= NULL" test.
diff --git a/Objects/call.c b/Objects/call.c
index 0d5c412..a1d0b33 100644
--- a/Objects/call.c
+++ b/Objects/call.c
@@ -30,12 +30,10 @@
 _Py_CheckFunctionResult(PyThreadState *tstate, PyObject *callable,
                         PyObject *result, const char *where)
 {
-    int err_occurred = (_PyErr_Occurred(tstate) != NULL);
-
     assert((callable != NULL) ^ (where != NULL));
 
     if (result == NULL) {
-        if (!err_occurred) {
+        if (!_PyErr_Occurred(tstate)) {
             if (callable)
                 _PyErr_Format(tstate, PyExc_SystemError,
                               "%R returned NULL without setting an error",
@@ -52,7 +50,7 @@
         }
     }
     else {
-        if (err_occurred) {
+        if (_PyErr_Occurred(tstate)) {
             Py_DECREF(result);
 
             if (callable) {
diff --git a/Objects/obmalloc.c b/Objects/obmalloc.c
index 50701db..722e91e 100644
--- a/Objects/obmalloc.c
+++ b/Objects/obmalloc.c
@@ -2313,12 +2313,13 @@
     return data;
 }
 
-static void
+static inline void
 _PyMem_DebugCheckGIL(void)
 {
-    if (!PyGILState_Check())
+    if (!PyGILState_Check()) {
         Py_FatalError("Python memory allocator called "
                       "without holding the GIL");
+    }
 }
 
 static void *