summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorIrit Katriel <1055913+iritkatriel@users.noreply.github.com>2023-03-18 11:47:11 +0000
committerGitHub <noreply@github.com>2023-03-18 11:47:11 +0000
commite1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7 (patch)
tree8363c72cc70b34e06fed5c39d86ec99047613799 /Python/pythonrun.c
parent039714d00f147be4d018fa6aeaf174aad7e8fa32 (diff)
downloadcpython-git-e1e9bab0061e8d4bd7b94ed455f3bb7bf8633ae7.tar.gz
gh-102778: Add sys.last_exc, deprecate sys.last_type, sys.last_value,sys.last_traceback (#102779)
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 07d119a678..6ea185a1b7 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -776,6 +776,10 @@ _PyErr_PrintEx(PyThreadState *tstate, int set_sys_last_vars)
}
if (set_sys_last_vars) {
+ if (_PySys_SetAttr(&_Py_ID(last_exc), exc) < 0) {
+ _PyErr_Clear(tstate);
+ }
+ /* Legacy version: */
if (_PySys_SetAttr(&_Py_ID(last_type), typ) < 0) {
_PyErr_Clear(tstate);
}