Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c6ecfcd

Browse files
committed
Minor correction to the stdprinter object.
1 parent 826d897 commit c6ecfcd

1 file changed

Lines changed: 4 additions & 2 deletions

File tree

Objects/fileobject.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -352,14 +352,16 @@ PyFile_NewStdPrinter(int fd)
352352
{
353353
PyStdPrinter_Object *self;
354354

355-
if (fd != 1 && fd != 2) {
355+
if (fd != fileno(stdout) && fd != fileno(stderr)) {
356356
PyErr_BadInternalCall();
357357
return NULL;
358358
}
359359

360360
self = PyObject_New(PyStdPrinter_Object,
361361
&PyStdPrinter_Type);
362-
self->fd = fd;
362+
if (self != NULL) {
363+
self->fd = fd;
364+
}
363365
return (PyObject*)self;
364366
}
365367

0 commit comments

Comments
 (0)