summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
Diffstat (limited to 'Objects')
-rw-r--r--Objects/fileobject.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index dc0f1fd..97c2756 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -352,14 +352,16 @@ PyFile_NewStdPrinter(int fd)
{
PyStdPrinter_Object *self;
- if (fd != 1 && fd != 2) {
+ if (fd != fileno(stdout) && fd != fileno(stderr)) {
PyErr_BadInternalCall();
return NULL;
}
self = PyObject_New(PyStdPrinter_Object,
&PyStdPrinter_Type);
- self->fd = fd;
+ if (self != NULL) {
+ self->fd = fd;
+ }
return (PyObject*)self;
}