diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2013-07-16 22:26:05 +0200 |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2013-07-16 22:26:05 +0200 |
commit | 1e53bbacedaed883104454693c29d1ad31f5029b (patch) | |
tree | e4fc2ec54fe409dd3e50fbd7ac756a43b103bbf8 /Python/bltinmodule.c | |
parent | 1b63493ed18a93201ad0c09bfc849a13d9f01632 (diff) | |
download | cpython-git-1e53bbacedaed883104454693c29d1ad31f5029b.tar.gz |
Issue #18408: handle PySys_GetObject() failure, raise a RuntimeError
Diffstat (limited to 'Python/bltinmodule.c')
-rw-r--r-- | Python/bltinmodule.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 949f029446..06d71f726c 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1550,6 +1550,11 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds) return NULL; if (file == NULL || file == Py_None) { file = PySys_GetObject("stdout"); + if (file == NULL) { + PyErr_SetString(PyExc_RuntimeError, "lost sys.stdout"); + return NULL; + } + /* sys.stdout may be None when FILE* stdout isn't connected */ if (file == Py_None) Py_RETURN_NONE; |