Skip to content

Commit 258ce25

Browse files
authored
MAINT: Fix METH_NOARGS function signatures (numpy#20368)
The METH_NOARGS calling convention is required to take a second PyObject* which will always be NULL. This is a continuation of numpy#19058
1 parent d4243a3 commit 258ce25

File tree

4 files changed

+18
-16
lines changed

4 files changed

+18
-16
lines changed

numpy/core/src/multiarray/methods.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2246,7 +2246,7 @@ array_dumps(PyArrayObject *self, PyObject *args, PyObject *kwds)
22462246

22472247

22482248
static PyObject *
2249-
array_sizeof(PyArrayObject *self)
2249+
array_sizeof(PyArrayObject *self, PyObject *NPY_UNUSED(args))
22502250
{
22512251
/* object + dimension and strides */
22522252
Py_ssize_t nbytes = Py_TYPE(self)->tp_basicsize +

numpy/core/src/multiarray/multiarraymodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4212,7 +4212,7 @@ normalize_axis_index(PyObject *NPY_UNUSED(self),
42124212

42134213

42144214
static PyObject *
4215-
_reload_guard(PyObject *NPY_UNUSED(self)) {
4215+
_reload_guard(PyObject *NPY_UNUSED(self), PyObject *NPY_UNUSED(args)) {
42164216
static int initialized = 0;
42174217

42184218
#if !defined(PYPY_VERSION)

numpy/core/src/multiarray/nditer_pywrap.c

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1190,7 +1190,7 @@ npyiter_resetbasepointers(NewNpyArrayIterObject *self)
11901190
}
11911191

11921192
static PyObject *
1193-
npyiter_reset(NewNpyArrayIterObject *self)
1193+
npyiter_reset(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
11941194
{
11951195
if (self->iter == NULL) {
11961196
PyErr_SetString(PyExc_ValueError,
@@ -1227,7 +1227,7 @@ npyiter_reset(NewNpyArrayIterObject *self)
12271227
* copied.
12281228
*/
12291229
static PyObject *
1230-
npyiter_copy(NewNpyArrayIterObject *self)
1230+
npyiter_copy(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
12311231
{
12321232
NewNpyArrayIterObject *iter;
12331233

@@ -1263,7 +1263,7 @@ npyiter_copy(NewNpyArrayIterObject *self)
12631263
}
12641264

12651265
static PyObject *
1266-
npyiter_iternext(NewNpyArrayIterObject *self)
1266+
npyiter_iternext(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
12671267
{
12681268
if (self->iter != NULL && self->iternext != NULL &&
12691269
!self->finished && self->iternext(self->iter)) {
@@ -1320,7 +1320,8 @@ npyiter_remove_axis(NewNpyArrayIterObject *self, PyObject *args)
13201320
}
13211321

13221322
static PyObject *
1323-
npyiter_remove_multi_index(NewNpyArrayIterObject *self)
1323+
npyiter_remove_multi_index(
1324+
NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
13241325
{
13251326
if (self->iter == NULL) {
13261327
PyErr_SetString(PyExc_ValueError,
@@ -1345,7 +1346,8 @@ npyiter_remove_multi_index(NewNpyArrayIterObject *self)
13451346
}
13461347

13471348
static PyObject *
1348-
npyiter_enable_external_loop(NewNpyArrayIterObject *self)
1349+
npyiter_enable_external_loop(
1350+
NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
13491351
{
13501352
if (self->iter == NULL) {
13511353
PyErr_SetString(PyExc_ValueError,
@@ -1370,7 +1372,7 @@ npyiter_enable_external_loop(NewNpyArrayIterObject *self)
13701372
}
13711373

13721374
static PyObject *
1373-
npyiter_debug_print(NewNpyArrayIterObject *self)
1375+
npyiter_debug_print(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
13741376
{
13751377
if (self->iter != NULL) {
13761378
NpyIter_DebugPrint(self->iter);
@@ -2315,7 +2317,7 @@ npyiter_ass_subscript(NewNpyArrayIterObject *self, PyObject *op,
23152317
}
23162318

23172319
static PyObject *
2318-
npyiter_enter(NewNpyArrayIterObject *self)
2320+
npyiter_enter(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
23192321
{
23202322
if (self->iter == NULL) {
23212323
PyErr_SetString(PyExc_RuntimeError, "operation on non-initialized iterator");
@@ -2326,7 +2328,7 @@ npyiter_enter(NewNpyArrayIterObject *self)
23262328
}
23272329

23282330
static PyObject *
2329-
npyiter_close(NewNpyArrayIterObject *self)
2331+
npyiter_close(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
23302332
{
23312333
NpyIter *iter = self->iter;
23322334
int ret;
@@ -2347,7 +2349,7 @@ static PyObject *
23472349
npyiter_exit(NewNpyArrayIterObject *self, PyObject *NPY_UNUSED(args))
23482350
{
23492351
/* even if called via exception handling, writeback any data */
2350-
return npyiter_close(self);
2352+
return npyiter_close(self, NULL);
23512353
}
23522354

23532355
static PyMethodDef npyiter_methods[] = {

numpy/core/src/multiarray/scalartypes.c.src

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ gentype_multiply(PyObject *m1, PyObject *m2)
229229
* #convert = Long*8, LongLong*2#
230230
*/
231231
static PyObject *
232-
@type@_bit_count(PyObject *self)
232+
@type@_bit_count(PyObject *self, PyObject *NPY_UNUSED(args))
233233
{
234234
@type@ scalar = PyArrayScalar_VAL(self, @Name@);
235235
uint8_t count = npy_popcount@c@(scalar);
@@ -1160,7 +1160,7 @@ gentype_size_get(PyObject *NPY_UNUSED(self), void *NPY_UNUSED(ignored))
11601160
}
11611161

11621162
static PyObject *
1163-
gentype_sizeof(PyObject *self)
1163+
gentype_sizeof(PyObject *self, PyObject *NPY_UNUSED(args))
11641164
{
11651165
Py_ssize_t nbytes;
11661166
PyObject * isz = gentype_itemsize_get(self, NULL);
@@ -1918,7 +1918,7 @@ static PyObject *
19181918
*/
19191919
/* Heavily copied from the builtin float.as_integer_ratio */
19201920
static PyObject *
1921-
@name@_as_integer_ratio(PyObject *self)
1921+
@name@_as_integer_ratio(PyObject *self, PyObject *NPY_UNUSED(args))
19221922
{
19231923
#if @is_half@
19241924
npy_double val = npy_half_to_double(PyArrayScalar_VAL(self, @Name@));
@@ -1999,7 +1999,7 @@ error:
19991999
* #c = f, f, , l#
20002000
*/
20012001
static PyObject *
2002-
@name@_is_integer(PyObject *self)
2002+
@name@_is_integer(PyObject *self, PyObject *NPY_UNUSED(args))
20032003
{
20042004
#if @is_half@
20052005
npy_double val = npy_half_to_double(PyArrayScalar_VAL(self, @Name@));
@@ -2022,7 +2022,7 @@ static PyObject *
20222022
/**end repeat**/
20232023

20242024
static PyObject *
2025-
integer_is_integer(PyObject *self) {
2025+
integer_is_integer(PyObject *self, PyObject *NPY_UNUSED(args)) {
20262026
Py_RETURN_TRUE;
20272027
}
20282028

0 commit comments

Comments
 (0)