diff Python/sysmodule.c @ 62189:d281ed59ff0b

sys_pyfile_write() does nothing if file is NULL mywrite() falls back to the C file object if sys_pyfile_write() returns an error. This patch fixes a segfault is Py_FatalError() is called in an early stage of Python initialization.
author Victor Stinner <victor.stinner@haypocalc.com>
date Tue, 08 Jun 2010 20:46:00 +0000
parents 600c23127207
children 1f37d082a9aa
line wrap: on
line diff
--- a/Python/sysmodule.c	Tue Jun 08 18:59:20 2010 +0000
+++ b/Python/sysmodule.c	Tue Jun 08 20:46:00 2010 +0000
@@ -1839,6 +1839,9 @@
     PyObject *unicode = NULL, *writer = NULL, *args = NULL, *result = NULL;
     int err;
 
+    if (file == NULL)
+        return -1;
+
     unicode = PyUnicode_FromString(text);
     if (unicode == NULL)
         goto error;