[Python-3000-checkins] r58926 - python/branches/py3k/Objects/fileobject.c
christian.heimes
python-3000-checkins at python.org
Sat Nov 10 01:30:14 CET 2007
Author: christian.heimes
Date: Sat Nov 10 01:30:14 2007
New Revision: 58926
Modified:
python/branches/py3k/Objects/fileobject.c
Log:
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.
Modified: python/branches/py3k/Objects/fileobject.c
==============================================================================
--- python/branches/py3k/Objects/fileobject.c (original)
+++ python/branches/py3k/Objects/fileobject.c Sat Nov 10 01:30:14 2007
@@ -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;
}
More information about the Python-3000-checkins
mailing list