From: Christian Heimes Date: Sat, 10 Nov 2007 00:30:14 +0000 (+0000) Subject: Bug #1415 X-Git-Tag: v3.0a2~208 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e018b305f6a4049b8832f712482cafec6beef5b7;p=thirdparty%2FPython%2Fcpython.git Bug #1415 On Windows fileno(stdout) and fileno(stderr) can return an invalid file descriptor number (-2 on my machine). It happens only for pythonw.exe but not for python.exe. Catch the problem ASAP in PyFile_NewStdPrinter(). I've also removed the call to PyErr_BadInternalCall(). It was causing a seg fault because the exceptions aren't available yet. --- diff --git a/Objects/fileobject.c b/Objects/fileobject.c index c6c7d8e2009a..c4feed1304e0 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -352,8 +352,8 @@ PyFile_NewStdPrinter(int fd) { PyStdPrinter_Object *self; - if (fd != fileno(stdout) && fd != fileno(stderr)) { - PyErr_BadInternalCall(); + if ((fd != fileno(stdout) && fd != fileno(stderr)) || fd < 0) { + /* not enough infrastructure for PyErr_BadInternalCall() */ return NULL; }