Author: christian.heimes
Date: Tue Nov 13 16:24:14 2007
New Revision: 58962

Modified:
   python/branches/py3k/Python/bltinmodule.c
Log:
Another #1415 fix for Windows GUI apps
print() mustn't raise an exception when sys.stdout is None.

Modified: python/branches/py3k/Python/bltinmodule.c
==============================================================================
--- python/branches/py3k/Python/bltinmodule.c   (original)
+++ python/branches/py3k/Python/bltinmodule.c   Tue Nov 13 16:24:14 2007
@@ -1192,9 +1192,13 @@
        }
        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,
_______________________________________________
Python-3000-checkins mailing list
[email protected]
http://mail.python.org/mailman/listinfo/python-3000-checkins

Reply via email to