]> granicus.if.org Git - python/commitdiff
Bug #1415
authorChristian Heimes <christian@cheimes.de>
Sat, 10 Nov 2007 00:30:14 +0000 (00:30 +0000)
committerChristian Heimes <christian@cheimes.de>
Sat, 10 Nov 2007 00:30:14 +0000 (00:30 +0000)
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.

Objects/fileobject.c

index c6c7d8e2009aaa1ead795cd69874fd23171c84b4..c4feed1304e01f61bb7ccf7a0192b6c7ff90cfb5 100644 (file)
@@ -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;
        }