mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
Another #1415 fix for Windows GUI apps
print() mustn't raise an exception when sys.stdout is None.
This commit is contained in:
parent
db23308c71
commit
fef9bbaff2
1 changed files with 6 additions and 2 deletions
|
@ -1192,9 +1192,13 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds)
|
||||||
}
|
}
|
||||||
if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOO:print",
|
if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOO:print",
|
||||||
kwlist, &sep, &end, &file))
|
kwlist, &sep, &end, &file))
|
||||||
return NULL;
|
return NULL;
|
||||||
if (file == NULL || file == Py_None)
|
if (file == NULL || file == Py_None) {
|
||||||
file = PySys_GetObject("stdout");
|
file = PySys_GetObject("stdout");
|
||||||
|
/* sys.stdout may be None when FILE* stdout isn't connected */
|
||||||
|
if (file == Py_None)
|
||||||
|
Py_RETURN_NONE;
|
||||||
|
}
|
||||||
|
|
||||||
if (sep && sep != Py_None && !PyUnicode_Check(sep)) {
|
if (sep && sep != Py_None && !PyUnicode_Check(sep)) {
|
||||||
PyErr_Format(PyExc_TypeError,
|
PyErr_Format(PyExc_TypeError,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue