summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Include/internal/pycore_pylifecycle.h2
-rw-r--r--Python/pylifecycle.c5
-rw-r--r--Python/pystate.c5
3 files changed, 8 insertions, 4 deletions
diff --git a/Include/internal/pycore_pylifecycle.h b/Include/internal/pycore_pylifecycle.h
index 2dd6149a6b..cf228033a7 100644
--- a/Include/internal/pycore_pylifecycle.h
+++ b/Include/internal/pycore_pylifecycle.h
@@ -83,7 +83,7 @@ extern void _PyHash_Fini(void);
extern void _PyTraceMalloc_Fini(void);
extern void _PyWarnings_Fini(PyInterpreterState *interp);
-extern void _PyGILState_Init(PyThreadState *tstate);
+extern PyStatus _PyGILState_Init(PyThreadState *tstate);
extern void _PyGILState_Fini(PyThreadState *tstate);
PyAPI_FUNC(void) _PyGC_DumpShutdownStats(PyThreadState *tstate);
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c
index d00bf821c5..bc32eff436 100644
--- a/Python/pylifecycle.c
+++ b/Python/pylifecycle.c
@@ -551,7 +551,10 @@ pycore_create_interpreter(_PyRuntimeState *runtime,
_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 a926e9753c..504f5f456d 100644
--- a/Python/pystate.c
+++ b/Python/pystate.c
@@ -1147,7 +1147,7 @@ PyThreadState_IsCurrent(PyThreadState *tstate)
/* 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 @@ _PyGILState_Init(PyThreadState *tstate)
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 *