Skip to content

Commit 34c1ea3

Browse files
authored
gh-111178: Fix function signatures for multiple tests (#131496)
1 parent 486d537 commit 34c1ea3

15 files changed

+112
-69
lines changed

Modules/_decimal/_decimal.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4995,8 +4995,9 @@ _dec_hash(PyDecObject *v)
49954995
}
49964996

49974997
static Py_hash_t
4998-
dec_hash(PyDecObject *self)
4998+
dec_hash(PyObject *op)
49994999
{
5000+
PyDecObject *self = _PyDecObject_CAST(op);
50005001
if (self->hash == -1) {
50015002
self->hash = _dec_hash(self);
50025003
}

Modules/_ssl.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,8 +451,9 @@ PyDoc_STRVAR(SSLEOFError_doc,
451451
"SSL/TLS connection terminated abruptly.");
452452

453453
static PyObject *
454-
SSLError_str(PyOSErrorObject *self)
454+
SSLError_str(PyObject *op)
455455
{
456+
PyOSErrorObject *self = (PyOSErrorObject*)op;
456457
if (self->strerror != NULL && PyUnicode_Check(self->strerror)) {
457458
return Py_NewRef(self->strerror);
458459
}

Modules/_testbuffer.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,8 +1778,9 @@ copy_structure(Py_buffer *base)
17781778
}
17791779

17801780
static PyObject *
1781-
ndarray_subscript(NDArrayObject *self, PyObject *key)
1781+
ndarray_subscript(PyObject *op, PyObject *key)
17821782
{
1783+
NDArrayObject *self = (NDArrayObject*)op;
17831784
NDArrayObject *nd;
17841785
ndbuf_t *ndbuf;
17851786
Py_buffer *base = &self->head->base;
@@ -1862,8 +1863,9 @@ ndarray_subscript(NDArrayObject *self, PyObject *key)
18621863

18631864

18641865
static int
1865-
ndarray_ass_subscript(NDArrayObject *self, PyObject *key, PyObject *value)
1866+
ndarray_ass_subscript(PyObject *op, PyObject *key, PyObject *value)
18661867
{
1868+
NDArrayObject *self = (NDArrayObject*)op;
18671869
NDArrayObject *nd;
18681870
Py_buffer *dest = &self->head->base;
18691871
Py_buffer src;
@@ -1907,7 +1909,7 @@ ndarray_ass_subscript(NDArrayObject *self, PyObject *key, PyObject *value)
19071909
if (PyObject_GetBuffer(value, &src, PyBUF_FULL_RO) == -1)
19081910
return -1;
19091911

1910-
nd = (NDArrayObject *)ndarray_subscript(self, key);
1912+
nd = (NDArrayObject *)ndarray_subscript((PyObject*)self, key);
19111913
if (nd != NULL) {
19121914
dest = &nd->head->base;
19131915
ret = copy_buffer(dest, &src);
@@ -1959,8 +1961,8 @@ slice_indices(PyObject *self, PyObject *args)
19591961

19601962
static PyMappingMethods ndarray_as_mapping = {
19611963
NULL, /* mp_length */
1962-
(binaryfunc)ndarray_subscript, /* mp_subscript */
1963-
(objobjargproc)ndarray_ass_subscript /* mp_ass_subscript */
1964+
ndarray_subscript, /* mp_subscript */
1965+
ndarray_ass_subscript /* mp_ass_subscript */
19641966
};
19651967

19661968
static PySequenceMethods ndarray_as_sequence = {

Modules/_testcapimodule.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2931,20 +2931,22 @@ typedef struct {
29312931
} PyGenericAliasObject;
29322932

29332933
static void
2934-
generic_alias_dealloc(PyGenericAliasObject *self)
2934+
generic_alias_dealloc(PyObject *op)
29352935
{
2936+
PyGenericAliasObject *self = (PyGenericAliasObject*)op;
29362937
Py_CLEAR(self->item);
29372938
Py_TYPE(self)->tp_free((PyObject *)self);
29382939
}
29392940

29402941
static PyObject *
2941-
generic_alias_mro_entries(PyGenericAliasObject *self, PyObject *bases)
2942+
generic_alias_mro_entries(PyObject *op, PyObject *bases)
29422943
{
2944+
PyGenericAliasObject *self = (PyGenericAliasObject*)op;
29432945
return PyTuple_Pack(1, self->item);
29442946
}
29452947

29462948
static PyMethodDef generic_alias_methods[] = {
2947-
{"__mro_entries__", _PyCFunction_CAST(generic_alias_mro_entries), METH_O, NULL},
2949+
{"__mro_entries__", generic_alias_mro_entries, METH_O, NULL},
29482950
{NULL} /* sentinel */
29492951
};
29502952

@@ -2953,7 +2955,7 @@ static PyTypeObject GenericAlias_Type = {
29532955
"GenericAlias",
29542956
sizeof(PyGenericAliasObject),
29552957
0,
2956-
.tp_dealloc = (destructor)generic_alias_dealloc,
2958+
.tp_dealloc = generic_alias_dealloc,
29572959
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
29582960
.tp_methods = generic_alias_methods,
29592961
};
@@ -3084,8 +3086,9 @@ ContainerNoGC_new(PyTypeObject *type, PyObject *args, PyObject *kwargs)
30843086
}
30853087

30863088
static void
3087-
ContainerNoGC_dealloc(ContainerNoGCobject *self)
3089+
ContainerNoGC_dealloc(PyObject *op)
30883090
{
3091+
ContainerNoGCobject *self = (ContainerNoGCobject*)op;
30893092
Py_DECREF(self->value);
30903093
Py_TYPE(self)->tp_free((PyObject *)self);
30913094
}
@@ -3100,7 +3103,7 @@ static PyTypeObject ContainerNoGC_type = {
31003103
PyVarObject_HEAD_INIT(NULL, 0)
31013104
"_testcapi.ContainerNoGC",
31023105
sizeof(ContainerNoGCobject),
3103-
.tp_dealloc = (destructor)ContainerNoGC_dealloc,
3106+
.tp_dealloc = ContainerNoGC_dealloc,
31043107
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
31053108
.tp_members = ContainerNoGC_members,
31063109
.tp_new = ContainerNoGC_new,

Modules/_testlimitedcapi/vectorcall_limited.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ LimitedVectorCallClass_vectorcall(PyObject *callable,
3030
}
3131

3232
static PyObject *
33-
LimitedVectorCallClass_new(PyTypeObject *tp, PyTypeObject *a, PyTypeObject *kw)
33+
LimitedVectorCallClass_new(PyTypeObject *tp, PyObject *a, PyObject *kw)
3434
{
3535
PyObject *self = ((allocfunc)PyType_GetSlot(tp, Py_tp_alloc))(tp, 0);
3636
if (!self) {
@@ -182,7 +182,7 @@ typedef struct {
182182
} LimitedRelativeVectorCallStruct;
183183

184184
static PyObject *
185-
LimitedRelativeVectorCallClass_new(PyTypeObject *tp, PyTypeObject *a, PyTypeObject *kw)
185+
LimitedRelativeVectorCallClass_new(PyTypeObject *tp, PyObject *a, PyObject *kw)
186186
{
187187
PyObject *self = ((allocfunc)PyType_GetSlot(tp, Py_tp_alloc))(tp, 0);
188188
if (!self) {

Modules/xxlimited_35.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Xxo_getattro(PyObject *op, PyObject *name)
100100
}
101101

102102
static int
103-
Xxo_setattr(PyObject *op, const char *name, PyObject *v)
103+
Xxo_setattr(PyObject *op, char *name, PyObject *v)
104104
{
105105
XxoObject *self = XxoObject_CAST(op);
106106
if (self->x_attr == NULL) {

Modules/zlibmodule.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1363,8 +1363,9 @@ class zlib.ZlibDecompressor "ZlibDecompressor *" "&ZlibDecompressorType"
13631363
/*[clinic end generated code: output=da39a3ee5e6b4b0d input=0658178ab94645df]*/
13641364

13651365
static void
1366-
ZlibDecompressor_dealloc(ZlibDecompressor *self)
1366+
ZlibDecompressor_dealloc(PyObject *op)
13671367
{
1368+
ZlibDecompressor *self = (ZlibDecompressor*)op;
13681369
PyObject *type = (PyObject *)Py_TYPE(self);
13691370
PyThread_free_lock(self->lock);
13701371
if (self->is_initialised) {

Objects/genobject.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,8 +1534,9 @@ async_gen_anext(PyObject *self)
15341534

15351535

15361536
static PyObject *
1537-
async_gen_asend(PyAsyncGenObject *o, PyObject *arg)
1537+
async_gen_asend(PyObject *op, PyObject *arg)
15381538
{
1539+
PyAsyncGenObject *o = (PyAsyncGenObject*)op;
15391540
if (async_gen_init_hooks(o)) {
15401541
return NULL;
15411542
}
@@ -1544,17 +1545,19 @@ async_gen_asend(PyAsyncGenObject *o, PyObject *arg)
15441545

15451546

15461547
static PyObject *
1547-
async_gen_aclose(PyAsyncGenObject *o, PyObject *arg)
1548+
async_gen_aclose(PyObject *op, PyObject *arg)
15481549
{
1550+
PyAsyncGenObject *o = (PyAsyncGenObject*)op;
15491551
if (async_gen_init_hooks(o)) {
15501552
return NULL;
15511553
}
15521554
return async_gen_athrow_new(o, NULL);
15531555
}
15541556

15551557
static PyObject *
1556-
async_gen_athrow(PyAsyncGenObject *o, PyObject *args)
1558+
async_gen_athrow(PyObject *op, PyObject *args)
15571559
{
1560+
PyAsyncGenObject *o = (PyAsyncGenObject*)op;
15581561
if (PyTuple_GET_SIZE(args) > 1) {
15591562
if (PyErr_WarnEx(PyExc_DeprecationWarning,
15601563
"the (type, exc, tb) signature of athrow() is deprecated, "
@@ -1625,9 +1628,9 @@ the (type, val, tb) signature is deprecated, \n\
16251628
and may be removed in a future version of Python.");
16261629

16271630
static PyMethodDef async_gen_methods[] = {
1628-
{"asend", (PyCFunction)async_gen_asend, METH_O, async_asend_doc},
1629-
{"athrow",(PyCFunction)async_gen_athrow, METH_VARARGS, async_athrow_doc},
1630-
{"aclose", (PyCFunction)async_gen_aclose, METH_NOARGS, async_aclose_doc},
1631+
{"asend", async_gen_asend, METH_O, async_asend_doc},
1632+
{"athrow", async_gen_athrow, METH_VARARGS, async_athrow_doc},
1633+
{"aclose", async_gen_aclose, METH_NOARGS, async_aclose_doc},
16311634
{"__sizeof__", gen_sizeof, METH_NOARGS, sizeof__doc__},
16321635
{"__class_getitem__", Py_GenericAlias,
16331636
METH_O|METH_CLASS, PyDoc_STR("See PEP 585")},
@@ -2324,8 +2327,9 @@ async_gen_athrow_close(PyObject *self, PyObject *args)
23242327

23252328

23262329
static void
2327-
async_gen_athrow_finalize(PyAsyncGenAThrow *o)
2330+
async_gen_athrow_finalize(PyObject *op)
23282331
{
2332+
PyAsyncGenAThrow *o = (PyAsyncGenAThrow*)op;
23292333
if (o->agt_state == AWAITABLE_STATE_INIT) {
23302334
PyObject *method = o->agt_args ? &_Py_ID(athrow) : &_Py_ID(aclose);
23312335
_PyErr_WarnUnawaitedAgenMethod(o->agt_gen, method);
@@ -2389,7 +2393,7 @@ PyTypeObject _PyAsyncGenAThrow_Type = {
23892393
0, /* tp_init */
23902394
0, /* tp_alloc */
23912395
0, /* tp_new */
2392-
.tp_finalize = (destructor)async_gen_athrow_finalize,
2396+
.tp_finalize = async_gen_athrow_finalize,
23932397
};
23942398

23952399

Objects/longobject.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6474,6 +6474,12 @@ long_long_meth(PyObject *self, PyObject *Py_UNUSED(ignored))
64746474
return long_long(self);
64756475
}
64766476

6477+
static PyObject *
6478+
long_long_getter(PyObject *self, void *Py_UNUSED(ignored))
6479+
{
6480+
return long_long(self);
6481+
}
6482+
64776483
/*[clinic input]
64786484
int.is_integer
64796485
@@ -6534,15 +6540,15 @@ static PyMethodDef long_methods[] = {
65346540

65356541
static PyGetSetDef long_getset[] = {
65366542
{"real",
6537-
(getter)long_long_meth, (setter)NULL,
6543+
long_long_getter, (setter)NULL,
65386544
"the real part of a complex number",
65396545
NULL},
65406546
{"imag",
65416547
long_get0, (setter)NULL,
65426548
"the imaginary part of a complex number",
65436549
NULL},
65446550
{"numerator",
6545-
(getter)long_long_meth, (setter)NULL,
6551+
long_long_getter, (setter)NULL,
65466552
"the numerator of a rational number in lowest terms",
65476553
NULL},
65486554
{"denominator",

Objects/picklebufobject.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -91,22 +91,25 @@ picklebuf_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
9191
}
9292

9393
static int
94-
picklebuf_traverse(PyPickleBufferObject *self, visitproc visit, void *arg)
94+
picklebuf_traverse(PyObject *op, visitproc visit, void *arg)
9595
{
96+
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
9697
Py_VISIT(self->view.obj);
9798
return 0;
9899
}
99100

100101
static int
101-
picklebuf_clear(PyPickleBufferObject *self)
102+
picklebuf_clear(PyObject *op)
102103
{
104+
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
103105
PyBuffer_Release(&self->view);
104106
return 0;
105107
}
106108

107109
static void
108-
picklebuf_dealloc(PyPickleBufferObject *self)
110+
picklebuf_dealloc(PyObject *op)
109111
{
112+
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
110113
PyObject_GC_UnTrack(self);
111114
if (self->weakreflist != NULL)
112115
PyObject_ClearWeakRefs((PyObject *) self);
@@ -117,8 +120,9 @@ picklebuf_dealloc(PyPickleBufferObject *self)
117120
/* Buffer API */
118121

119122
static int
120-
picklebuf_getbuf(PyPickleBufferObject *self, Py_buffer *view, int flags)
123+
picklebuf_getbuf(PyObject *op, Py_buffer *view, int flags)
121124
{
125+
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
122126
if (self->view.obj == NULL) {
123127
PyErr_SetString(PyExc_ValueError,
124128
"operation forbidden on released PickleBuffer object");
@@ -128,7 +132,7 @@ picklebuf_getbuf(PyPickleBufferObject *self, Py_buffer *view, int flags)
128132
}
129133

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

140144
static PyBufferProcs picklebuf_as_buffer = {
141-
.bf_getbuffer = (getbufferproc) picklebuf_getbuf,
142-
.bf_releasebuffer = (releasebufferproc) picklebuf_releasebuf,
145+
.bf_getbuffer = picklebuf_getbuf,
146+
.bf_releasebuffer = picklebuf_releasebuf,
143147
};
144148

145149
/* Methods */
146150

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

187192
static PyObject *
188-
picklebuf_release(PyPickleBufferObject *self, PyObject *Py_UNUSED(ignored))
193+
picklebuf_release(PyObject *op, PyObject *Py_UNUSED(ignored))
189194
{
195+
PyPickleBufferObject *self = (PyPickleBufferObject*)op;
190196
PyBuffer_Release(&self->view);
191197
Py_RETURN_NONE;
192198
}
@@ -197,8 +203,8 @@ PyDoc_STRVAR(picklebuf_release_doc,
197203
Release the underlying buffer exposed by the PickleBuffer object.");
198204

199205
static PyMethodDef picklebuf_methods[] = {
200-
{"raw", (PyCFunction) picklebuf_raw, METH_NOARGS, picklebuf_raw_doc},
201-
{"release", (PyCFunction) picklebuf_release, METH_NOARGS, picklebuf_release_doc},
206+
{"raw", picklebuf_raw, METH_NOARGS, picklebuf_raw_doc},
207+
{"release", picklebuf_release, METH_NOARGS, picklebuf_release_doc},
202208
{NULL, NULL}
203209
};
204210

@@ -209,9 +215,9 @@ PyTypeObject PyPickleBuffer_Type = {
209215
.tp_basicsize = sizeof(PyPickleBufferObject),
210216
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
211217
.tp_new = picklebuf_new,
212-
.tp_dealloc = (destructor) picklebuf_dealloc,
213-
.tp_traverse = (traverseproc) picklebuf_traverse,
214-
.tp_clear = (inquiry) picklebuf_clear,
218+
.tp_dealloc = picklebuf_dealloc,
219+
.tp_traverse = picklebuf_traverse,
220+
.tp_clear = picklebuf_clear,
215221
.tp_weaklistoffset = offsetof(PyPickleBufferObject, weakreflist),
216222
.tp_as_buffer = &picklebuf_as_buffer,
217223
.tp_methods = picklebuf_methods,

Objects/setobject.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -816,8 +816,9 @@ setiter_traverse(PyObject *self, visitproc visit, void *arg)
816816
}
817817

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

829830
static PyObject *
830-
setiter_reduce(setiterobject *si, PyObject *Py_UNUSED(ignored))
831+
setiter_reduce(PyObject *op, PyObject *Py_UNUSED(ignored))
831832
{
833+
setiterobject *si = (setiterobject*)op;
834+
832835
/* copy the iterator state */
833836
setiterobject tmp = *si;
834837
Py_XINCREF(tmp.si_set);
@@ -845,8 +848,8 @@ setiter_reduce(setiterobject *si, PyObject *Py_UNUSED(ignored))
845848
PyDoc_STRVAR(reduce_doc, "Return state information for pickling.");
846849

847850
static PyMethodDef setiter_methods[] = {
848-
{"__length_hint__", (PyCFunction)setiter_len, METH_NOARGS, length_hint_doc},
849-
{"__reduce__", (PyCFunction)setiter_reduce, METH_NOARGS, reduce_doc},
851+
{"__length_hint__", setiter_len, METH_NOARGS, length_hint_doc},
852+
{"__reduce__", setiter_reduce, METH_NOARGS, reduce_doc},
850853
{NULL, NULL} /* sentinel */
851854
};
852855

0 commit comments

Comments
 (0)