summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <victor.stinner@gmail.com>2013-07-22 21:55:19 (GMT)
committerVictor Stinner <victor.stinner@gmail.com>2013-07-22 21:55:19 (GMT)
commitba30883f60271be3b4b8c14735566c943a83c68f (patch)
treeb7d1564d9607a5327664d6db3001c410905de4dc
parent5b3b1006bbb25902a6981b3447032d2b743be4c4 (diff)
downloadcpython-ba30883f60271be3b4b8c14735566c943a83c68f.zip
cpython-ba30883f60271be3b4b8c14735566c943a83c68f.tar.gz
cpython-ba30883f60271be3b4b8c14735566c943a83c68f.tar.bz2
Issue #18520: Fix initstdio(), handle PySys_SetObject() failure
-rw-r--r--Python/pythonrun.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 30e5e6f..18c2baa 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