8000 gh-111178: Fix function signatures for PyStdPrinter by vstinner · Pull Request #131192 · python/cpython · GitHub
[go: up one dir, main page]

Skip to content

gh-111178: Fix function signatures for PyStdPrinter #131192

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 14, 2025
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 number Diff line number Diff 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 Down Expand 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 Down Expand 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
Loading
0