diff options
author | Christian Heimes <christian@cheimes.de> | 2007-11-13 15:24:14 (GMT) |
---|---|---|
committer | Christian Heimes <christian@cheimes.de> | 2007-11-13 15:24:14 (GMT) |
commit | fef9bbaff2513f1b17f5aa2b9a44e3d32855f082 (patch) | |
tree | 9cdac4c3dedf72f6406eb0a2789c65c1e4389043 | |
parent | db23308c7111239fadbc4ac95da38ec22a9bbf88 (diff) | |
download | cpython-fef9bbaff2513f1b17f5aa2b9a44e3d32855f082.zip cpython-fef9bbaff2513f1b17f5aa2b9a44e3d32855f082.tar.gz cpython-fef9bbaff2513f1b17f5aa2b9a44e3d32855f082.tar.bz2 |
Another #1415 fix for Windows GUI apps
print() mustn't raise an exception when sys.stdout is None.
-rw-r--r-- | Python/bltinmodule.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 7973fcb..755bfc1 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, |