summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorxdegaye <xdegaye@gmail.com>2017-10-24 16:42:33 +0200
committerGitHub <noreply@github.com>2017-10-24 16:42:33 +0200
commitd5d79545b73110b2f4c2b66d150409514e2ca8e0 (patch)
treeda81cc88b7d37daca21b3c993f64eda0c3c2fa01 /Python/pythonrun.c
parentd8f78a1fbc0a34224289d436ad67f608fa553f0c (diff)
downloadcpython-git-d5d79545b73110b2f4c2b66d150409514e2ca8e0.tar.gz
[3.6] bpo-30817: Fix PyErr_PrintEx() when no memory (GH-2526). (#4107)
(cherry picked from commit 66caacf2f0d6213b049a3097556e28e30440b900)
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index bf651d0ff8..6a9722bee5 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -624,9 +624,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) {