Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions Objects/fileobject.c
Original file line numberDiff line numberDiff line change
Expand Up@@ -303,8 +303,9 @@ PyFile_NewStdPrinter(int fd)
}

static PyObject *
stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
stdprinter_write(PyObject *op, PyObject *args)
{
PyStdPrinter_Object *self = (PyStdPrinter_Object*)op;
PyObject *unicode;
PyObject *bytes = NULL;
const char *str;
Expand DownExpand Up@@ -355,27 +356,30 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
}

static PyObject *
stdprinter_fileno(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
stdprinter_fileno(PyObject *op, PyObject *Py_UNUSED(ignored))
{
PyStdPrinter_Object *self = (PyStdPrinter_Object*)op;
return PyLong_FromLong((long) self->fd);
}

static PyObject *
stdprinter_repr(PyStdPrinter_Object *self)
stdprinter_repr(PyObject *op)
{
PyStdPrinter_Object *self = (PyStdPrinter_Object*)op;
return PyUnicode_FromFormat("<stdprinter(fd=%d) object at %p>",
self->fd, self);
}

static PyObject *
stdprinter_noop(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
stdprinter_noop(PyObject *self, PyObject *Py_UNUSED(ignored))
{
Py_RETURN_NONE;
}

static PyObject *
stdprinter_isatty(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
stdprinter_isatty(PyObject *op, PyObject *Py_UNUSED(ignored))
{
PyStdPrinter_Object *self = (PyStdPrinter_Object*)op;
long res;
if (self->fd < 0) {
Py_RETURN_FALSE;
Expand All@@ -389,11 +393,11 @@ stdprinter_isatty(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
}

static PyMethodDef stdprinter_methods[] = {
{"close", (PyCFunction)stdprinter_noop, METH_NOARGS, ""},
{"flush", (PyCFunction)stdprinter_noop, METH_NOARGS, ""},
{"fileno", (PyCFunction)stdprinter_fileno, METH_NOARGS, ""},
{"isatty", (PyCFunction)stdprinter_isatty, METH_NOARGS, ""},
{"write", (PyCFunction)stdprinter_write, METH_VARARGS, ""},
{"close", stdprinter_noop, METH_NOARGS, ""},
{"flush", stdprinter_noop, METH_NOARGS, ""},
{"fileno", stdprinter_fileno, METH_NOARGS, ""},
{"isatty", stdprinter_isatty, METH_NOARGS, ""},
{"write", stdprinter_write, METH_VARARGS, ""},
{NULL, NULL} /*sentinel */
};

Expand DownExpand Up@@ -433,7 +437,7 @@ PyTypeObject PyStdPrinter_Type = {
0, /* tp_getattr */
0, /* tp_setattr */
0, /* tp_as_async */
(reprfunc)stdprinter_repr, /* tp_repr */
stdprinter_repr, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
Expand Down