From: Victor Stinner Date: Tue, 8 Jun 2010 20:46:00 +0000 (+0000) Subject: sys_pyfile_write() does nothing if file is NULL X-Git-Tag: v3.2a1~595 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ecccc4f9b888ddfba057119e33e03b4c1ffdfe0e;p=python 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. --- diff --git a/Python/sysmodule.c b/Python/sysmodule.c index f1da9730c4..9ec8ab1489 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -1839,6 +1839,9 @@ sys_pyfile_write(const char *text, PyObject *file) 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;