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.
This commit is contained in:
Victor Stinner 2019-11-07 12:42:07 +01:00 committed by GitHub
parent 991b02dc87
commit d12d0e7c0f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 12 additions and 7 deletions

View file

@ -218,6 +218,9 @@ PyErr_SetString(PyObject *exception, const char *string)
PyObject* _Py_HOT_FUNCTION
PyErr_Occurred(void)
{
/* The caller must hold the GIL. */
assert(PyGILState_Check());
PyThreadState *tstate = _PyThreadState_GET();
return _PyErr_Occurred(tstate);
}