summaryrefslogtreecommitdiff
path: root/Python/pythonrun.c
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-22 23:55:19 +0200
committerVictor Stinner <victor.stinner@gmail.com>2013-07-22 23:55:19 +0200
commit7196af1e77661d5981f36256a627831392e8c220 (patch)
tree1f190da0a622bef7eb7e8a1e32a5ed742178dbc7 /Python/pythonrun.c
parent015fad13eabce6c057cbdb62ae93ea80b4803718 (diff)
downloadcpython-7196af1e77661d5981f36256a627831392e8c220.tar.gz
Issue #18520: Fix initstdio(), handle PySys_SetObject() failure
Diffstat (limited to 'Python/pythonrun.c')
-rw-r--r--Python/pythonrun.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 30e5e6f0c3..18c2baa656 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -1159,8 +1159,14 @@ initstdio(void)
}
PyErr_Clear(); /* Not a fatal error if codec isn't available */
- PySys_SetObject("__stderr__", std);
- PySys_SetObject("stderr", std);
+ if (PySys_SetObject("__stderr__", std) < 0) {
+ Py_DECREF(std);
+ goto error;
+ }
+ if (PySys_SetObject("stderr", std) < 0) {
+ Py_DECREF(std);
+ goto error;
+ }
Py_DECREF(std);
#endif