]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111178: Fix function signatures for PyStdPrinter (#131192)
authorVictor Stinner <vstinner@python.org>
Fri, 14 Mar 2025 09:24:38 +0000 (10:24 +0100)
committerGitHub <noreply@github.com>
Fri, 14 Mar 2025 09:24:38 +0000 (10:24 +0100)
Objects/fileobject.c

index 7025b5bcffc1c8f080d35184920980a49994f961..c9a20ccd75324aa6549829140c25e6e8f8349d72 100644 (file)
@@ -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;
@@ -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;
@@ -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 */
 };
 
@@ -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 */