diff options
author | xdegaye <xdegaye@gmail.com> | 2017-10-23 18:08:41 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-10-23 18:08:41 +0200 |
commit | 66caacf2f0d6213b049a3097556e28e30440b900 (patch) | |
tree | 8485c0ccc79d52485f59529370bd71d30be798c6 /Python/pythonrun.c | |
parent | 4ffd4653a7ec9c97775472276cf5e159e2366bb2 (diff) | |
download | cpython-git-66caacf2f0d6213b049a3097556e28e30440b900.tar.gz |
bpo-30817: Fix PyErr_PrintEx() when no memory (#2526)
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r-- | Python/pythonrun.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c index 25e2da44d9..17ec182b74 100644 --- a/Python/pythonrun.c +++ b/Python/pythonrun.c @@ -630,9 +630,15 @@ PyErr_PrintEx(int set_sys_last_vars) return; /* Now we know v != NULL too */ if (set_sys_last_vars) { - _PySys_SetObjectId(&PyId_last_type, exception); - _PySys_SetObjectId(&PyId_last_value, v); - _PySys_SetObjectId(&PyId_last_traceback, tb); + if (_PySys_SetObjectId(&PyId_last_type, exception) < 0) { + PyErr_Clear(); + } + if (_PySys_SetObjectId(&PyId_last_value, v) < 0) { + PyErr_Clear(); + } + if (_PySys_SetObjectId(&PyId_last_traceback, tb) < 0) { + PyErr_Clear(); + } } hook = _PySys_GetObjectId(&PyId_excepthook); if (hook) { |