aboutsummaryrefslogtreecommitdiff
path: root/Python/errors.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2019-11-07 12:42:07 +0100
committerGitHub <noreply@github.com>2019-11-07 12:42:07 +0100
commitd12d0e7c0fe2b49c40ac4d66365147c619d6c475 (patch)
tree9ccd0a4fdb77f4c9ee169c9f775eab2de78bffd0 /Python/errors.c
parent991b02dc871e101e98edece37d8a570f6a39d79f (diff)
downloadcpython3-d12d0e7c0fe2b49c40ac4d66365147c619d6c475.tar.gz
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.
Diffstat (limited to 'Python/errors.c')
-rw-r--r--Python/errors.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/Python/errors.c b/Python/errors.c
index 9658afeb9f..1783084c33 100644
--- a/Python/errors.c
+++ b/Python/errors.c
@@ -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);
}