Skip to content

gh-111178: Fix function signatures for multiple tests #131496

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 20, 2025
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion Modules/_decimal/_decimal.c
Original file line number Diff line number Diff line change
Expand Up @@ -4995,8 +4995,9 @@ _dec_hash(PyDecObject *v)
}

static Py_hash_t
dec_hash(PyDecObject *self)
dec_hash(PyObject *op)
{
PyDecObject *self = _PyDecObject_CAST(op);
if (self->hash == -1) {
self->hash = _dec_hash(self);
}
Expand Down
3 changes: 2 additions & 1 deletion Modules/_ssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,9 @@ PyDoc_STRVAR(SSLEOFError_doc,
"SSL/TLS connection terminated abruptly.");

static PyObject *
SSLError_str(PyOSErrorObject *self)
SSLError_str(PyObject *op)
{
PyOSErrorObject *self = (PyOSErrorObject*)op;
if (self->strerror != NULL && PyUnicode_Check(self->strerror)) {
return Py_NewRef(self->strerror);
}
Expand Down
12 changes: 7 additions & 5 deletions Modules/_testbuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1778,8 +1778,9 @@ copy_structure(Py_buffer *base)
}

static PyObject *
ndarray_subscript(NDArrayObject *self, PyObject *key)
ndarray_subscript(PyObject *op, PyObject *key)
{
NDArrayObject *self = (NDArrayObject*)op;
NDArrayObject *nd;
ndbuf_t *ndbuf;
Py_buffer *base = &self->head->base;
Expand Down Expand Up @@ -1862,8 +1863,9 @@ ndarray_subscript(NDArrayObject *self, PyObject *key)


static int
ndarray_ass_subscript(NDArrayObject *self, PyObject *key, PyObject *value)
ndarray_ass_subscript(PyObject *op, PyObject *key, PyObject *value)
{
NDArrayObject *self = (NDArrayObject*)op;
NDArrayObject *nd;
Py_buffer *dest = &self->head->base;
Py_buffer src;
Expand Down Expand Up @@ -1907,7 +1909,7 @@ ndarray_ass_subscript(NDArrayObject *self, PyObject *key, PyObject *value)
if (PyObject_GetBuffer(value, &src, PyBUF_FULL_RO) == -1)
return -1;

nd = (NDArrayObject *)ndarray_subscript(self, key);
nd = (NDArrayObject *)ndarray_subscript((PyObject*)self, key);
if (nd != NULL) {
dest = &nd->head->base;
ret = copy_buffer(dest, &src);
Expand Down Expand Up @@ -1959,8 +1961,8 @@ slice_indices(PyObject *self, PyObject *args)

static PyMappingMethods ndarray_as_mapping = {
NULL, /* mp_length */
(binaryfunc)ndarray_subscript, /* mp_subscript */
(objobjargproc)ndarray_ass_subscript /* mp_ass_subscript */
ndarray_subscript, /* mp_subscript */
ndarray_ass_subscript /* mp_ass_subscript */
};

static PySequenceMethods ndarray_as_sequence = {
Expand Down
15 changes: 9 additions & 6 deletions Modules/_testcapimodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -2931,20 +2931,22 @@ typedef struct {
} PyGenericAliasObject;

static void
generic_alias_dealloc(PyGenericAliasObject *self)
generic_alias_dealloc(PyObject *op)
{
PyGenericAliasObject *self = (PyGenericAliasObject*)op;
Py_CLEAR(self->item);
Py_TYPE(self)->tp_free((PyObject *)self);
}

static PyObject *
generic_alias_mro_entries(PyGenericAliasObject *self, PyObject *bases)
generic_alias_mro_entries(PyObject *op, PyObject *bases)
{
PyGenericAliasObject *self = (PyGenericAliasObject*)op;
return PyTuple_Pack(1, self->item);
}

static PyMethodDef generic_alias_methods[] = {
{"__mro_entries__", _PyCFunction_CAST(generic_alias_mro_entries), METH_O, NULL},
{"__mro_entries__", generic_alias_mro_entries, METH_O, NULL},
{NULL} /* sentinel */
};

Expand All @@ -2953,7 +2955,7 @@ static PyTypeObject GenericAlias_Type = {
"GenericAlias",
sizeof(PyGenericAliasObject),
0,
.tp_dealloc = (destructor)generic_alias_dealloc,
.tp_dealloc = generic_alias_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_methods = generic_alias_methods,
};
Expand Down Expand Up @@ -3084,8 +3086,9 @@ ContainerNoGC_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
}

static void
ContainerNoGC_dealloc(ContainerNoGCobject *self)
ContainerNoGC_dealloc(PyObject *op)
{
ContainerNoGCobject *self = (ContainerNoGCobject*)op;
Py_DECREF(self->value);
Py_TYPE(self)->tp_free((PyObject *)self);
}
Expand All @@ -3100,7 +3103,7 @@ static PyTypeObject ContainerNoGC_type = {
PyVarObject_HEAD_INIT(NULL, 0)
"_testcapi.ContainerNoGC",
sizeof(ContainerNoGCobject),
.tp_dealloc = (destructor)ContainerNoGC_dealloc,
.tp_dealloc = ContainerNoGC_dealloc,
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
.tp_members = ContainerNoGC_members,
.tp_new = ContainerNoGC_new,
Expand Down
4 changes: 2 additions & 2 deletions Modules/_testlimitedcapi/vectorcall_limited.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ LimitedVectorCallClass_vectorcall(PyObject *callable,
}

static PyObject *
LimitedVectorCallClass_new(PyTypeObject *tp, PyTypeObject *a, PyTypeObject *kw)
LimitedVectorCallClass_new(PyTypeObject *tp, PyObject *a, PyObject *kw)
{
PyObject *self = ((allocfunc)PyType_GetSlot(tp, Py_tp_alloc))(tp, 0);
if (!self) {
Expand Down Expand Up @@ -182,7 +182,7 @@ typedef struct {
} LimitedRelativeVectorCallStruct;

static PyObject *
LimitedRelativeVectorCallClass_new(PyTypeObject *tp, PyTypeObject *a, PyTypeObject *kw)
LimitedRelativeVectorCallClass_new(PyTypeObject *tp, PyObject *a, PyObject *kw)
{
PyObject *self = ((allocfunc)PyType_GetSlot(tp, Py_tp_alloc))(tp, 0);
if (!self) {
Expand Down
2 changes: 1 addition & 1 deletion Modules/xxlimited_35.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Xxo_getattro(PyObject *op, PyObject *name)
}

static int
Xxo_setattr(PyObject *op, const char *name, PyObject *v)
Xxo_setattr(PyObject *op, char *name, PyObject *v)
{
XxoObject *self = XxoObject_CAST(op);
if (self->x_attr == NULL) {
Expand Down
3 changes: 2 additions & 1 deletion Modules/zlibmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -1363,8 +1363,9 @@ class zlib.ZlibDecompressor "ZlibDecompressor *" "&ZlibDecompressorType"
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=0658178ab94645df]*/

static void
ZlibDecompressor_dealloc(ZlibDecompressor *self)
ZlibDecompressor_dealloc(PyObject *op)
{
ZlibDecompressor *self = (ZlibDecompressor*)op;
PyObject *type = (PyObject *)Py_TYPE(self);
PyThread_free_lock(self->lock);
if (self->is_initialised) {
Expand Down
20 changes: 12 additions & 8 deletions Objects/genobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -1534,8 +1534,9 @@ async_gen_anext(PyObject *self)


static PyObject *
async_gen_asend(PyAsyncGenObject *o, PyObject *arg)
async_gen_asend(PyObject *op, PyObject *arg)
{
PyAsyncGenObject *o = (PyAsyncGenObject*)op;
if (async_gen_init_hooks(o)) {
return NULL;
}
Expand All @@ -1544,17 +1545,19 @@ async_gen_asend(PyAsyncGenObject *o, PyObject *arg)


static PyObject *
async_gen_aclose(PyAsyncGenObject *o, PyObject *arg)
async_gen_aclose(PyObject *op, PyObject *arg)
{
PyAsyncGenObject *o = (PyAsyncGenObject*)op;
if (async_gen_init_hooks(o)) {
return NULL;
}
return async_gen_athrow_new(o, NULL);
}

static PyObject *
async_gen_athrow(PyAsyncGenObject *o, PyObject *args)
async_gen_athrow(PyObject *op, PyObject *args)
{
PyAsyncGenObject *o = (PyAsyncGenObject*)op;
if (PyTuple_GET_SIZE(args) > 1) {
if (PyErr_WarnEx(PyExc_DeprecationWarning,
"the (type, exc, tb) signature of athrow() is deprecated, "
Expand Down Expand Up @@ -1625,9 +1628,9 @@ the (type, val, tb) signature is deprecated, \n\
and may be removed in a future version of Python.");

static PyMethodDef async_gen_methods[] = {
{"asend", (PyCFunction)async_gen_asend, METH_O, async_asend_doc},
{"athrow",(PyCFunction)async_gen_athrow, METH_VARARGS, async_athrow_doc},
{"aclose", (PyCFunction)async_gen_aclose, METH_NOARGS, async_aclose_doc},
{"asend", async_gen_asend, METH_O, async_asend_doc},
{"athrow", async_gen_athrow, METH_VARARGS, async_athrow_doc},
{"aclose", async_gen_aclose, METH_NOARGS, async_aclose_doc},
{"__sizeof__", gen_sizeof, METH_NOARGS, sizeof__doc__},
{"__class_getitem__", Py_GenericAlias,
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
Expand Down Expand Up @@ -2324,8 +2327,9 @@ async_gen_athrow_close(PyObject *self, PyObject *args)


static void
async_gen_athrow_finalize(PyAsyncGenAThrow *o)
async_gen_athrow_finalize(PyObject *op)
{
PyAsyncGenAThrow *o = (PyAsyncGenAThrow*)op;
if (o->agt_state == AWAITABLE_STATE_INIT) {
PyObject *method = o->agt_args ? &_Py_ID(athrow) : &_Py_ID(aclose);
_PyErr_WarnUnawaitedAgenMethod(o->agt_gen, method);
Expand Down Expand Up @@ -2389,7 +2393,7 @@ PyTypeObject _PyAsyncGenAThrow_Type = {
0, /* tp_init */
0, /* tp_alloc */
0, /* tp_new */
.tp_finalize = (destructor)async_gen_athrow_finalize,
.tp_finalize = async_gen_athrow_finalize,
};


Expand Down
10 changes: 8 additions & 2 deletions Objects/longobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -6474,6 +6474,12 @@ long_long_meth(PyObject *self, PyObject *Py_UNUSED(ignored))
return long_long(self);
}

static PyObject *
long_long_getter(PyObject *self, void *Py_UNUSED(ignored))
{
return long_long(self);
}

/*[clinic input]
int.is_integer

Expand Down Expand Up @@ -6534,15 +6540,15 @@ static PyMethodDef long_methods[] = {

static PyGetSetDef long_getset[] = {
{"real",
(getter)long_long_meth, (setter)NULL,
long_long_getter, (setter)NULL,
"the real part of a complex number",
NULL},
{"imag",
long_get0, (setter)NULL,
"the imaginary part of a complex number",
NULL},
{"numerator",
(getter)long_long_meth, (setter)NULL,
long_long_getter, (setter)NULL,
"the numerator of a rational number in lowest terms",
NULL},
{"denominator",
Expand Down
34 changes: 20 additions & 14 deletions Objects/picklebufobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,22 +91,25 @@ picklebuf_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
}

static int
picklebuf_traverse(PyPickleBufferObject *self, visitproc visit, void *arg)
picklebuf_traverse(PyObject *op, visitproc visit, void *arg)
{
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
Py_VISIT(self->view.obj);
return 0;
}

static int
picklebuf_clear(PyPickleBufferObject *self)
picklebuf_clear(PyObject *op)
{
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
PyBuffer_Release(&self->view);
return 0;
}

static void
picklebuf_dealloc(PyPickleBufferObject *self)
picklebuf_dealloc(PyObject *op)
{
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
PyObject_GC_UnTrack(self);
if (self->weakreflist != NULL)
PyObject_ClearWeakRefs((PyObject *) self);
Expand All @@ -117,8 +120,9 @@ picklebuf_dealloc(PyPickleBufferObject *self)
/* Buffer API */

static int
picklebuf_getbuf(PyPickleBufferObject *self, Py_buffer *view, int flags)
picklebuf_getbuf(PyObject *op, Py_buffer *view, int flags)
{
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
if (self->view.obj == NULL) {
PyErr_SetString(PyExc_ValueError,
"operation forbidden on released PickleBuffer object");
Expand All @@ -128,7 +132,7 @@ picklebuf_getbuf(PyPickleBufferObject *self, Py_buffer *view, int flags)
}

static void
picklebuf_releasebuf(PyPickleBufferObject *self, Py_buffer *view)
picklebuf_releasebuf(PyObject *self, Py_buffer *view)
{
/* Since our bf_getbuffer redirects to the original object, this
* implementation is never called. It only exists to signal that
Expand All @@ -138,15 +142,16 @@ picklebuf_releasebuf(PyPickleBufferObject *self, Py_buffer *view)
}

static PyBufferProcs picklebuf_as_buffer = {
.bf_getbuffer = (getbufferproc) picklebuf_getbuf,
.bf_releasebuffer = (releasebufferproc) picklebuf_releasebuf,
.bf_getbuffer = picklebuf_getbuf,
.bf_releasebuffer = picklebuf_releasebuf,
};

/* Methods */

static PyObject *
picklebuf_raw(PyPickleBufferObject *self, PyObject *Py_UNUSED(ignored))
picklebuf_raw(PyObject *op, PyObject *Py_UNUSED(ignored))
{
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
if (self->view.obj == NULL) {
PyErr_SetString(PyExc_ValueError,
"operation forbidden on released PickleBuffer object");
Expand Down Expand Up @@ -185,8 +190,9 @@ Return a memoryview of the raw memory underlying this buffer.\n\
Will raise BufferError is the buffer isn't contiguous.");

static PyObject *
picklebuf_release(PyPickleBufferObject *self, PyObject *Py_UNUSED(ignored))
picklebuf_release(PyObject *op, PyObject *Py_UNUSED(ignored))
{
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
PyBuffer_Release(&self->view);
Py_RETURN_NONE;
}
Expand All @@ -197,8 +203,8 @@ PyDoc_STRVAR(picklebuf_release_doc,
Release the underlying buffer exposed by the PickleBuffer object.");

static PyMethodDef picklebuf_methods[] = {
{"raw", (PyCFunction) picklebuf_raw, METH_NOARGS, picklebuf_raw_doc},
{"release", (PyCFunction) picklebuf_release, METH_NOARGS, picklebuf_release_doc},
{"raw", picklebuf_raw, METH_NOARGS, picklebuf_raw_doc},
{"release", picklebuf_release, METH_NOARGS, picklebuf_release_doc},
{NULL, NULL}
};

Expand All @@ -209,9 +215,9 @@ PyTypeObject PyPickleBuffer_Type = {
.tp_basicsize = sizeof(PyPickleBufferObject),
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
.tp_new = picklebuf_new,
.tp_dealloc = (destructor) picklebuf_dealloc,
.tp_traverse = (traverseproc) picklebuf_traverse,
.tp_clear = (inquiry) picklebuf_clear,
.tp_dealloc = picklebuf_dealloc,
.tp_traverse = picklebuf_traverse,
.tp_clear = picklebuf_clear,
.tp_weaklistoffset = offsetof(PyPickleBufferObject, weakreflist),
.tp_as_buffer = &picklebuf_as_buffer,
.tp_methods = picklebuf_methods,
Expand Down
11 changes: 7 additions & 4 deletions Objects/setobject.c
Original file line number Diff line number Diff line change
Expand Up @@ -816,8 +816,9 @@ setiter_traverse(PyObject *self, visitproc visit, void *arg)
}

static PyObject *
setiter_len(setiterobject *si, PyObject *Py_UNUSED(ignored))
setiter_len(PyObject *op, PyObject *Py_UNUSED(ignored))
{
setiterobject *si = (setiterobject*)op;
Py_ssize_t len = 0;
if (si->si_set != NULL && si->si_used == si->si_set->used)
len = si->len;
Expand All @@ -827,8 +828,10 @@ setiter_len(setiterobject *si, PyObject *Py_UNUSED(ignored))
PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it)).");

static PyObject *
setiter_reduce(setiterobject *si, PyObject *Py_UNUSED(ignored))
setiter_reduce(PyObject *op, PyObject *Py_UNUSED(ignored))
{
setiterobject *si = (setiterobject*)op;

/* copy the iterator state */
setiterobject tmp = *si;
Py_XINCREF(tmp.si_set);
Expand All @@ -845,8 +848,8 @@ setiter_reduce(setiterobject *si, PyObject *Py_UNUSED(ignored))
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");

static PyMethodDef setiter_methods[] = {
{"__length_hint__", (PyCFunction)setiter_len, METH_NOARGS, length_hint_doc},
{"__reduce__", (PyCFunction)setiter_reduce, METH_NOARGS, reduce_doc},
{"__length_hint__", setiter_len, METH_NOARGS, length_hint_doc},
{"__reduce__", setiter_reduce, METH_NOARGS, reduce_doc},
{NULL, NULL} /* sentinel */
};

Expand Down
Loading
Loading