mirror of
https://github.com/python/cpython.git
synced 2025-07-09 20:35:26 +00:00
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.
This commit is contained in:
parent
ec3c99c8a7
commit
17c68b8107
2 changed files with 5 additions and 11 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue