mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Issue #18408: handle PySys_GetObject() failure, raise a RuntimeError
This commit is contained in:
parent
1b63493ed1
commit
1e53bbaced
4 changed files with 22 additions and 9 deletions
|
@ -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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue