]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Minor correction to the stdprinter object.
authorGuido van Rossum <guido@python.org>
Tue, 30 Oct 2007 18:36:44 +0000 (18:36 +0000)
committerGuido van Rossum <guido@python.org>
Tue, 30 Oct 2007 18:36:44 +0000 (18:36 +0000)
Objects/fileobject.c

index dc0f1fd1473383375c3e41918ab94908b69a44d2..97c2756ac4d64db501878db0c01dc63ce50e0aa4 100644 (file)
@@ -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;
 }