summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-11-10 00:30:14 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-11-10 00:30:14 (GMT)
commite018b305f6a4049b8832f712482cafec6beef5b7 (patch)
tree944aff9e120608a0c2c997876dafc14894840a91 /Objects
parent3ab4f651b906e47650c6b6de94ae23da08db4f58 (diff)
downloadcpython-e018b305f6a4049b8832f712482cafec6beef5b7.zip
cpython-e018b305f6a4049b8832f712482cafec6beef5b7.tar.gz
cpython-e018b305f6a4049b8832f712482cafec6beef5b7.tar.bz2
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.
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index c6c7d8e..c4feed1 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;
}