Skip to content

Commit d56b539

Browse files
committed
pythongh-111178: Fix function signatures for PyStdPrinter
1 parent 9a63138 commit d56b539

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

Objects/fileobject.c

+15-11
Original file line numberDiff line numberDiff line change
@@ -303,8 +303,9 @@ PyFile_NewStdPrinter(int fd)
303303
}
304304

305305
static PyObject *
306-
stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
306+
stdprinter_write(PyObject *op, PyObject *args)
307307
{
308+
PyStdPrinter_Object *self = (PyStdPrinter_Object*)op;
308309
PyObject *unicode;
309310
PyObject *bytes = NULL;
310311
const char *str;
@@ -355,27 +356,30 @@ stdprinter_write(PyStdPrinter_Object *self, PyObject *args)
355356
}
356357

357358
static PyObject *
358-
stdprinter_fileno(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
359+
stdprinter_fileno(PyObject *op, PyObject *Py_UNUSED(ignored))
359360
{
361+
PyStdPrinter_Object *self = (PyStdPrinter_Object*)op;
360362
return PyLong_FromLong((long) self->fd);
361363
}
362364

363365
static PyObject *
364-
stdprinter_repr(PyStdPrinter_Object *self)
366+
stdprinter_repr(PyObject *op)
365367
{
368+
PyStdPrinter_Object *self = (PyStdPrinter_Object*)op;
366369
return PyUnicode_FromFormat("<stdprinter(fd=%d) object at %p>",
367370
self->fd, self);
368371
}
369372

370373
static PyObject *
371-
stdprinter_noop(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
374+
stdprinter_noop(PyObject *self, PyObject *Py_UNUSED(ignored))
372375
{
373376
Py_RETURN_NONE;
374377
}
375378

376379
static PyObject *
377-
stdprinter_isatty(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
380+
stdprinter_isatty(PyObject *op, PyObject *Py_UNUSED(ignored))
378381
{
382+
PyStdPrinter_Object *self = (PyStdPrinter_Object*)op;
379383
long res;
380384
if (self->fd < 0) {
381385
Py_RETURN_FALSE;
@@ -389,11 +393,11 @@ stdprinter_isatty(PyStdPrinter_Object *self, PyObject *Py_UNUSED(ignored))
389393
}
390394

391395
static PyMethodDef stdprinter_methods[] = {
392-
{"close", (PyCFunction)stdprinter_noop, METH_NOARGS, ""},
393-
{"flush", (PyCFunction)stdprinter_noop, METH_NOARGS, ""},
394-
{"fileno", (PyCFunction)stdprinter_fileno, METH_NOARGS, ""},
395-
{"isatty", (PyCFunction)stdprinter_isatty, METH_NOARGS, ""},
396-
{"write", (PyCFunction)stdprinter_write, METH_VARARGS, ""},
396+
{"close", stdprinter_noop, METH_NOARGS, ""},
397+
{"flush", stdprinter_noop, METH_NOARGS, ""},
398+
{"fileno", stdprinter_fileno, METH_NOARGS, ""},
399+
{"isatty", stdprinter_isatty, METH_NOARGS, ""},
400+
{"write", stdprinter_write, METH_VARARGS, ""},
397401
{NULL, NULL} /*sentinel */
398402
};
399403

@@ -433,7 +437,7 @@ PyTypeObject PyStdPrinter_Type = {
433437
0, /* tp_getattr */
434438
0, /* tp_setattr */
435439
0, /* tp_as_async */
436-
(reprfunc)stdprinter_repr, /* tp_repr */
440+
stdprinter_repr, /* tp_repr */
437441
0, /* tp_as_number */
438442
0, /* tp_as_sequence */
439443
0, /* tp_as_mapping */

0 commit comments

Comments
 (0)