bpo-38631: _PyGILState_Init() returns PyStatus (GH-18908)

_PyGILState_Init() now returns PyStatus rather than calling
Py_FatalError() on failure.
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index d00bf82..bc32eff 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -551,7 +551,10 @@
     _PyEval_FiniThreads(&runtime->ceval);
 
     /* Auto-thread-state API */
-    _PyGILState_Init(tstate);
+    status = _PyGILState_Init(tstate);
+    if (_PyStatus_EXCEPTION(status)) {
+        return status;
+    }
 
     /* Create the GIL */
     status = _PyEval_InitThreads(tstate);
diff --git a/Python/pystate.c b/Python/pystate.c
index a926e97..504f5f4 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1147,7 +1147,7 @@
 /* Internal initialization/finalization functions called by
    Py_Initialize/Py_FinalizeEx
 */
-void
+PyStatus
 _PyGILState_Init(PyThreadState *tstate)
 {
     /* must init with valid states */
@@ -1157,13 +1157,14 @@
     struct _gilstate_runtime_state *gilstate = &tstate->interp->runtime->gilstate;
 
     if (PyThread_tss_create(&gilstate->autoTSSkey) != 0) {
-        Py_FatalError("Could not allocate TSS entry");
+        return _PyStatus_NO_MEMORY();
     }
     gilstate->autoInterpreterState = tstate->interp;
     assert(PyThread_tss_get(&gilstate->autoTSSkey) == NULL);
     assert(tstate->gilstate_counter == 0);
 
     _PyGILState_NoteThreadState(gilstate, tstate);
+    return _PyStatus_OK();
 }
 
 PyInterpreterState *