From: Christian Heimes Date: Tue, 13 Nov 2007 15:24:14 +0000 (+0000) Subject: Another #1415 fix for Windows GUI apps X-Git-Tag: v3.0a2~192 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fef9bbaff2513f1b17f5aa2b9a44e3d32855f082;p=python Another #1415 fix for Windows GUI apps print() mustn't raise an exception when sys.stdout is None. --- diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 7973fcb662..755bfc1b38 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1192,9 +1192,13 @@ builtin_print(PyObject *self, PyObject *args, PyObject *kwds) } if (!PyArg_ParseTupleAndKeywords(dummy_args, kwds, "|OOO:print", kwlist, &sep, &end, &file)) - return NULL; - if (file == NULL || file == Py_None) + return NULL; + if (file == NULL || file == Py_None) { 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)) { PyErr_Format(PyExc_TypeError,