Commit e018b305 authored by Christian Heimes's avatar Christian Heimes

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.
parent 3ab4f651
......@@ -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;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment