mirror of https://github.com/python/cpython.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.
This commit is contained in:
parent
3ab4f651b9
commit
e018b305f6
|
@ -352,8 +352,8 @@ PyFile_NewStdPrinter(int fd)
|
||||||
{
|
{
|
||||||
PyStdPrinter_Object *self;
|
PyStdPrinter_Object *self;
|
||||||
|
|
||||||
if (fd != fileno(stdout) && fd != fileno(stderr)) {
|
if ((fd != fileno(stdout) && fd != fileno(stderr)) || fd < 0) {
|
||||||
PyErr_BadInternalCall();
|
/* not enough infrastructure for PyErr_BadInternalCall() */
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue