From ae3087c6382011c47db82fea4d05f8bbf514265d Mon Sep 17 00:00:00 2001 From: Mark Shannon Date: Sun, 22 Oct 2017 22:41:51 +0100 Subject: Move exc state to generator. Fixes bpo-25612 (#1773) Move exception state information from frame objects to coroutine (generator/thread) object where it belongs. --- Python/sysmodule.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'Python/sysmodule.c') diff --git a/Python/sysmodule.c b/Python/sysmodule.c index e38a200c00..6dc8e08be7 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -311,14 +311,13 @@ PyDoc_STRVAR(excepthook_doc, static PyObject * sys_exc_info(PyObject *self, PyObject *noargs) { - PyThreadState *tstate; - tstate = PyThreadState_GET(); + _PyErr_StackItem *err_info = _PyErr_GetTopmostException(PyThreadState_GET()); return Py_BuildValue( "(OOO)", - tstate->exc_type != NULL ? tstate->exc_type : Py_None, - tstate->exc_value != NULL ? tstate->exc_value : Py_None, - tstate->exc_traceback != NULL ? - tstate->exc_traceback : Py_None); + err_info->exc_type != NULL ? err_info->exc_type : Py_None, + err_info->exc_value != NULL ? err_info->exc_value : Py_None, + err_info->exc_traceback != NULL ? + err_info->exc_traceback : Py_None); } PyDoc_STRVAR(exc_info_doc, -- cgit v1.2.1