diff Objects/fileobject.c @ 43811:20dc6786f9ac

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.
author Christian Heimes <christian@cheimes.de>
date Sat, 10 Nov 2007 00:30:14 +0000
parents 0d462d789b18
children 8ed3a95ca114
line wrap: on
line diff
--- a/Objects/fileobject.c	Fri Nov 09 01:27:29 2007 +0000
+++ b/Objects/fileobject.c	Sat Nov 10 00:30:14 2007 +0000
@@ -352,8 +352,8 @@
 {
 	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;
 	}