diff options
author | Victor Stinner <vstinner@python.org> | 2020-01-30 11:20:48 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-30 11:20:48 (GMT) |
commit | 17c68b8107e348aeaaa05f7ac5072cacff916022 (patch) | |
tree | 31a937cee879bb5cf9c9433eecdb336da1ebf058 /Python | |
parent | ec3c99c8a73650d7833189bd973ec492564aa479 (diff) | |
download | cpython-17c68b8107e348aeaaa05f7ac5072cacff916022.zip cpython-17c68b8107e348aeaaa05f7ac5072cacff916022.tar.gz cpython-17c68b8107e348aeaaa05f7ac5072cacff916022.tar.bz2 |
bpo-38631: Replace Py_FatalError() with assert() in ceval.c (GH-18279)
Replace a few Py_FatalError() calls if tstate is NULL with
assert(tstate != NULL) in ceval.c.
PyEval_AcquireThread(), PyEval_ReleaseThread() and
PyEval_RestoreThread() must never be called with a NULL tstate.
Diffstat (limited to 'Python')
-rw-r--r-- | Python/ceval.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/Python/ceval.c b/Python/ceval.c index 2770dc6..2bf64ed 100644 --- a/Python/ceval.c +++ b/Python/ceval.c @@ -302,9 +302,7 @@ PyEval_ReleaseLock(void) void PyEval_AcquireThread(PyThreadState *tstate) { - if (tstate == NULL) { - Py_FatalError("PyEval_AcquireThread: NULL new thread state"); - } + assert(tstate != NULL); _PyRuntimeState *runtime = tstate->interp->runtime; struct _ceval_runtime_state *ceval = &runtime->ceval; @@ -321,9 +319,7 @@ PyEval_AcquireThread(PyThreadState *tstate) void PyEval_ReleaseThread(PyThreadState *tstate) { - if (tstate == NULL) { - Py_FatalError("PyEval_ReleaseThread: NULL thread state"); - } + assert(tstate != NULL); _PyRuntimeState *runtime = tstate->interp->runtime; PyThreadState *new_tstate = _PyThreadState_Swap(&runtime->gilstate, NULL); @@ -385,12 +381,10 @@ PyEval_SaveThread(void) void PyEval_RestoreThread(PyThreadState *tstate) { + assert(tstate != NULL); + _PyRuntimeState *runtime = tstate->interp->runtime; struct _ceval_runtime_state *ceval = &runtime->ceval; - - if (tstate == NULL) { - Py_FatalError("PyEval_RestoreThread: NULL tstate"); - } assert(gil_created(&ceval->gil)); int err = errno; |