Mercurial > cpython-lru_cache-weakref
diff Python/bltinmodule.c @ 84676:6bd01a59762a
Issue #18408: handle PySys_GetObject() failure, raise a RuntimeError
| author | Victor Stinner <victor.stinner@gmail.com> |
|---|---|
| date | Tue, 16 Jul 2013 22:26:05 +0200 |
| parents | 38b42ffdf86b |
| children | a5d9e2f3f6c7 |
line wrap: on
line diff
--- a/Python/bltinmodule.c Tue Jul 16 22:24:44 2013 +0200 +++ b/Python/bltinmodule.c Tue Jul 16 22:26:05 2013 +0200 @@ -1550,6 +1550,11 @@ 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;
