diff options
author | Irit Katriel <1055913+iritkatriel@users.noreply.github.com> | 2021-12-17 14:46:22 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-12-17 14:46:22 (GMT) |
commit | 396b58345f81d4c8c5a52546d2288e666a1b9b8b (patch) | |
tree | 89140d0930da874df676cfac27d2e85e746a5fc1 /Python/errors.c | |
parent | 62a0a2a25dbe3ba6f2973a37a3022d982fdc163c (diff) | |
download | cpython-396b58345f81d4c8c5a52546d2288e666a1b9b8b.zip cpython-396b58345f81d4c8c5a52546d2288e666a1b9b8b.tar.gz cpython-396b58345f81d4c8c5a52546d2288e666a1b9b8b.tar.bz2 |
bpo-45711: Remove type and traceback from exc_info (GH-30122)
* Do not PUSH/POP traceback or type to the stack as part of exc_info
* Remove exc_traceback and exc_type from _PyErr_StackItem
* Add to what's new, because this change breaks things like Cython
Diffstat (limited to 'Python/errors.c')
-rw-r--r-- | Python/errors.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/Python/errors.c b/Python/errors.c index 5be15e5..6c5fe41 100644 --- a/Python/errors.c +++ b/Python/errors.c @@ -84,11 +84,8 @@ _PyErr_GetTopmostException(PyThreadState *tstate) while ((exc_info->exc_value == NULL || exc_info->exc_value == Py_None) && exc_info->previous_item != NULL) { - assert(exc_info->exc_type == NULL || exc_info->exc_type == Py_None); exc_info = exc_info->previous_item; } - assert(exc_info->previous_item == NULL || - (exc_info->exc_type != NULL && exc_info->exc_type != Py_None)); return exc_info; } @@ -524,27 +521,17 @@ PyErr_GetExcInfo(PyObject **p_type, PyObject **p_value, PyObject **p_traceback) void PyErr_SetExcInfo(PyObject *type, PyObject *value, PyObject *traceback) { - PyObject *oldtype, *oldvalue, *oldtraceback; PyThreadState *tstate = _PyThreadState_GET(); - oldtype = tstate->exc_info->exc_type; - oldvalue = tstate->exc_info->exc_value; - oldtraceback = tstate->exc_info->exc_traceback; - + PyObject *oldvalue = tstate->exc_info->exc_value; - tstate->exc_info->exc_type = get_exc_type(value); - Py_XINCREF(tstate->exc_info->exc_type); tstate->exc_info->exc_value = value; - tstate->exc_info->exc_traceback = get_exc_traceback(value); - Py_XINCREF(tstate->exc_info->exc_traceback); /* These args are no longer used, but we still need to steal a ref */ Py_XDECREF(type); Py_XDECREF(traceback); - Py_XDECREF(oldtype); Py_XDECREF(oldvalue); - Py_XDECREF(oldtraceback); } @@ -629,9 +616,6 @@ _PyErr_ChainStackItem(_PyErr_StackItem *exc_info) exc_info_given = 1; } - assert( (exc_info->exc_type == NULL || exc_info->exc_type == Py_None) == - (exc_info->exc_value == NULL || exc_info->exc_value == Py_None) ); - if (exc_info->exc_value == NULL || exc_info->exc_value == Py_None) { return; } |