From b37737d470af5d983cc4422d1cc49a8b745a27e9 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Sun, 3 Dec 2023 23:24:52 -0600 Subject: [PATCH 001/120] Update _localemodule.c ./Modules/_localemodule.c:897:5: warning: cast from 'void (*)(PyObject *)' (aka 'void (*)(struct _object *)') to 'freefunc' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] 897 | (freefunc)locale_free, | ^~~~~~~~~~~~~~~~~~~~~ Objects/moduleobject.c:735:9: runtime error: call to function locale_free through pointer to incorrect function type 'void (*)(void *)' _localemodule.c:884: note: locale_free defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/moduleobject.c:735:9 in --- Modules/_localemodule.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index fe8e4c5e30035b..4b77f50f960e1e 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -880,8 +880,9 @@ locale_clear(PyObject *module) } static void -locale_free(PyObject *module) +locale_free(void *ptr) { + PyObject *module = ptr; locale_clear(module); } @@ -894,7 +895,7 @@ static struct PyModuleDef _localemodule = { _locale_slots, locale_traverse, locale_clear, - (freefunc)locale_free, + locale_free, }; PyMODINIT_FUNC From b8a97b1b91c5b71931bfbdb62266c72e110ecbb5 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:34:47 -0600 Subject: [PATCH 002/120] Update listobject.c Objects/listobject.c:3167:5: warning: cast from 'PyObject *(*)(PyListObject *)' (aka 'struct _object *(*)(PyListObject *)') to 'reprfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 3167 | (reprfunc)list_repr, /* tp_repr */ | ^~~~~~~~~~~~~~~~~~~ Example UBSan -fsanitize=function error: Objects/object.c:674:11: runtime error: call to function list_repr through pointer to incorrect function type 'struct _object *(*)(struct _object *)' listobject.c:382: note: list_repr defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:674:11 in --- Objects/listobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 2d04218439bd20..b2256464d490bc 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -378,8 +378,9 @@ list_dealloc(PyListObject *op) } static PyObject * -list_repr(PyListObject *v) +list_repr(PyObject *obj) { + PyListObject *v = (PyListObject *)obj; Py_ssize_t i; PyObject *s; _PyUnicodeWriter writer; @@ -3164,7 +3165,7 @@ PyTypeObject PyList_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)list_repr, /* tp_repr */ + list_repr, /* tp_repr */ 0, /* tp_as_number */ &list_as_sequence, /* tp_as_sequence */ &list_as_mapping, /* tp_as_mapping */ From 7fbd2e824ab75535b7c4759b262a60d068955747 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:38:09 -0600 Subject: [PATCH 003/120] Update listobject.c Objects/listobject.c:3162:5: warning: cast from 'void (*)(PyListObject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 3162 | (destructor)list_dealloc, /* tp_dealloc */ | ^~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:2857:5: runtime error: call to function list_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' listobject.c:347: note: list_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:2857:5 in --- Objects/listobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index b2256464d490bc..0189554a9e0f7d 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -343,8 +343,9 @@ PyList_Append(PyObject *op, PyObject *newitem) /* Methods */ static void -list_dealloc(PyListObject *op) +list_dealloc(PyObject *obj) { + PyListObject *op = (PyListObject *)obj; Py_ssize_t i; PyObject_GC_UnTrack(op); Py_TRASHCAN_BEGIN(op, list_dealloc) @@ -3160,7 +3161,7 @@ PyTypeObject PyList_Type = { "list", sizeof(PyListObject), 0, - (destructor)list_dealloc, /* tp_dealloc */ + list_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ From b1ae37f74c5706ce5f10653eba505325668791a1 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:41:43 -0600 Subject: [PATCH 004/120] Update listobject.c Objects/listobject.c:3181:5: warning: cast from 'int (*)(PyListObject *, visitproc, void *)' (aka 'int (*)(PyListObject *, int (*)(struct _object *, void *), void *)') to 'traverseproc' (aka 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)') converts to incompatible function type [-Wcast-function-type-strict] 3181 | (traverseproc)list_traverse, /* tp_traverse */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Modules/gcmodule.c:493:16: runtime error: call to function list_traverse through pointer to incorrect function type 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)' listobject.c:2760: note: list_traverse defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Modules/gcmodule.c:493:16 in --- Objects/listobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 0189554a9e0f7d..1aebbbb133dbba 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2758,8 +2758,9 @@ list_remove(PyListObject *self, PyObject *value) } static int -list_traverse(PyListObject *o, visitproc visit, void *arg) +list_traverse(PyObject *obj, visitproc visit, void *arg) { + PyListObject *o = (PyListObject *)obj; Py_ssize_t i; for (i = Py_SIZE(o); --i >= 0; ) @@ -3180,7 +3181,7 @@ PyTypeObject PyList_Type = { Py_TPFLAGS_BASETYPE | Py_TPFLAGS_LIST_SUBCLASS | _Py_TPFLAGS_MATCH_SELF | Py_TPFLAGS_SEQUENCE, /* tp_flags */ list___init____doc__, /* tp_doc */ - (traverseproc)list_traverse, /* tp_traverse */ + list_traverse, /* tp_traverse */ (inquiry)list_clear_slot, /* tp_clear */ list_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ From a63b588108447e550a4d4189192a65f8dbcb93cd Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:46:44 -0600 Subject: [PATCH 005/120] Update listobject.c Objects/listobject.c:3182:5: warning: cast from 'int (*)(PyListObject *)' to 'inquiry' (aka 'int (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 3182 | (inquiry)list_clear_slot, /* tp_clear */ | ^~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Modules/gcmodule.c:1033:24: runtime error: call to function list_clear_slot through pointer to incorrect function type 'int (*)(struct _object *)' listobject.c:620: note: list_clear_slot defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Modules/gcmodule.c:1033:24 in --- Objects/listobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 1aebbbb133dbba..6f5a7c4ee1acb0 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -618,8 +618,9 @@ list_clear(PyListObject *a) } static int -list_clear_slot(PyListObject *self) +list_clear_slot(PyObject *obj) { + PyListObject *self = (PyListObject *)obj; list_clear(self); return 0; } @@ -3182,7 +3183,7 @@ PyTypeObject PyList_Type = { _Py_TPFLAGS_MATCH_SELF | Py_TPFLAGS_SEQUENCE, /* tp_flags */ list___init____doc__, /* tp_doc */ list_traverse, /* tp_traverse */ - (inquiry)list_clear_slot, /* tp_clear */ + list_clear_slot, /* tp_clear */ list_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ list_iter, /* tp_iter */ From 4429afd57e2894e49aed99d24a54831d35bdab23 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:56:19 -0600 Subject: [PATCH 006/120] Update longobject.c Objects/longobject.c:6288:5: warning: cast from 'Py_hash_t (*)(PyLongObject *)' (aka 'long (*)(struct _longobject *)') to 'hashfunc' (aka 'long (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 6288 | (hashfunc)long_hash, /* tp_hash */ | ^~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:999:16: runtime error: call to function long_hash through pointer to incorrect function type 'long (*)(struct _object *)' longobject.c:3296: note: long_hash defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:999:16 in --- Objects/longobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c index fae70dd13bb18a..84a6b12a39b631 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -3292,8 +3292,9 @@ long_dealloc(PyObject *self) } static Py_hash_t -long_hash(PyLongObject *v) +long_hash(PyObject *obj) { + PyLongObject *v = (PyLongObject *)obj; Py_uhash_t x; Py_ssize_t i; int sign; @@ -6285,7 +6286,7 @@ PyTypeObject PyLong_Type = { &long_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - (hashfunc)long_hash, /* tp_hash */ + long_hash, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ From e2437b226821a00f444275deb1d4976e1442cc54 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:58:10 -0600 Subject: [PATCH 007/120] Update longobject.c Objects/longobject.c:6246:5: warning: cast from 'PyObject *(*)(PyLongObject *)' (aka 'struct _object *(*)(struct _longobject *)') to 'unaryfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 6246 | (unaryfunc)long_abs, /*tp_absolute*/ | ^~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/abstract.c:1442:25: runtime error: call to function long_abs through pointer to incorrect function type 'struct _object *(*)(struct _object *)' longobject.c:4882: note: long_abs defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:1442:25 in --- Objects/longobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c index 84a6b12a39b631..31c0de753c7d26 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -4879,8 +4879,9 @@ long_neg(PyLongObject *v) } static PyObject * -long_abs(PyLongObject *v) +long_abs(PyObject *obj) { + PyLongObject *v = (PyLongObject *)obj; if (_PyLong_IsNegative(v)) return long_neg(v); else @@ -6244,7 +6245,7 @@ static PyNumberMethods long_as_number = { long_pow, /*nb_power*/ (unaryfunc)long_neg, /*nb_negative*/ long_long, /*tp_positive*/ - (unaryfunc)long_abs, /*tp_absolute*/ + long_abs, /*tp_absolute*/ (inquiry)long_bool, /*tp_bool*/ (unaryfunc)long_invert, /*nb_invert*/ long_lshift, /*nb_lshift*/ From f106596df0d49d9d6a805e5a73a714879a97a304 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 02:29:02 -0600 Subject: [PATCH 008/120] Update longobject.c Objects/longobject.c:6244:5: warning: cast from 'PyObject *(*)(PyLongObject *)' (aka 'struct _object *(*)(struct _longobject *)') to 'unaryfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 6244 | (unaryfunc)long_neg, /*nb_negative*/ | ^~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/abstract.c:1391:25: runtime error: call to function long_neg through pointer to incorrect function type 'struct _object *(*)(struct _object *)' longobject.c:4870: note: long_neg defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:1391:25 in --- Objects/longobject.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c index 31c0de753c7d26..4b9e9cace9e8df 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -2299,8 +2299,6 @@ long_from_binary_base(const char *start, const char *end, Py_ssize_t digits, int return 0; } -static PyObject *long_neg(PyLongObject *v); - #ifdef WITH_PYLONG_MODULE /* asymptotically faster str-to-long conversion for base 10, using _pylong.py */ static int @@ -4867,8 +4865,9 @@ long_invert(PyLongObject *v) } static PyObject * -long_neg(PyLongObject *v) +long_neg(PyObject *obj) { + PyLongObject *v = (PyLongObject *)obj; PyLongObject *z; if (_PyLong_IsCompact(v)) return _PyLong_FromSTwoDigits(-medium_value(v)); @@ -4883,7 +4882,7 @@ long_abs(PyObject *obj) { PyLongObject *v = (PyLongObject *)obj; if (_PyLong_IsNegative(v)) - return long_neg(v); + return long_neg((PyObject *)v); else return long_long((PyObject *)v); } @@ -5725,7 +5724,7 @@ _PyLong_DivmodNear(PyObject *a, PyObject *b) if (twice_rem == NULL) goto error; if (quo_is_neg) { - temp = long_neg((PyLongObject*)twice_rem); + temp = long_neg(twice_rem); Py_SETREF(twice_rem, temp); if (twice_rem == NULL) goto error; @@ -5813,7 +5812,7 @@ int___round___impl(PyObject *self, PyObject *o_ndigits) } /* result = self - divmod_near(self, 10 ** -ndigits)[1] */ - temp = long_neg((PyLongObject*)ndigits); + temp = long_neg(ndigits); Py_SETREF(ndigits, temp); if (ndigits == NULL) return NULL; @@ -6243,7 +6242,7 @@ static PyNumberMethods long_as_number = { long_mod, /*nb_remainder*/ long_divmod, /*nb_divmod*/ long_pow, /*nb_power*/ - (unaryfunc)long_neg, /*nb_negative*/ + long_neg, /*nb_negative*/ long_long, /*tp_positive*/ long_abs, /*tp_absolute*/ (inquiry)long_bool, /*tp_bool*/ From e72dd7d1afa88334908fc1ffee031acb42a9cebf Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 02:31:32 -0600 Subject: [PATCH 009/120] Update longobject.c Objects/longobject.c:6248:5: warning: cast from 'PyObject *(*)(PyLongObject *)' (aka 'struct _object *(*)(struct _longobject *)') to 'unaryfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 6248 | (unaryfunc)long_invert, /*nb_invert*/ | ^~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/abstract.c:1425:25: runtime error: call to function long_invert through pointer to incorrect function type 'struct _object *(*)(struct _object *)' longobject.c:4854: note: long_invert defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:1425:25 in --- Objects/longobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c index 4b9e9cace9e8df..0a252ccd7bcfd0 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -4849,8 +4849,9 @@ long_pow(PyObject *v, PyObject *w, PyObject *x) } static PyObject * -long_invert(PyLongObject *v) +long_invert(PyObject *obj) { + PyLongObject *v = (PyLongObject *)obj; /* Implement ~x as -(x+1) */ PyLongObject *x; if (_PyLong_IsCompact(v)) @@ -6246,7 +6247,7 @@ static PyNumberMethods long_as_number = { long_long, /*tp_positive*/ long_abs, /*tp_absolute*/ (inquiry)long_bool, /*tp_bool*/ - (unaryfunc)long_invert, /*nb_invert*/ + long_invert, /*nb_invert*/ long_lshift, /*nb_lshift*/ long_rshift, /*nb_rshift*/ long_and, /*nb_and*/ From 19f356b3fd3a883e8efc417fb6bd3c41d6af3241 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 02:34:16 -0600 Subject: [PATCH 010/120] Update longobject.c Objects/longobject.c:6247:5: warning: cast from 'int (*)(PyLongObject *)' (aka 'int (*)(struct _longobject *)') to 'inquiry' (aka 'int (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 6247 | (inquiry)long_bool, /*tp_bool*/ | ^~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:1817:15: runtime error: call to function long_bool through pointer to incorrect function type 'int (*)(struct _object *)' longobject.c:4891: note: long_bool defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:1817:15 in --- Objects/longobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c index 0a252ccd7bcfd0..eb4abc415d8187 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -4889,8 +4889,9 @@ long_abs(PyObject *obj) } static int -long_bool(PyLongObject *v) +long_bool(PyObject *obj) { + PyLongObject *v = (PyLongObject *)obj; return !_PyLong_IsZero(v); } @@ -6246,7 +6247,7 @@ static PyNumberMethods long_as_number = { long_neg, /*nb_negative*/ long_long, /*tp_positive*/ long_abs, /*tp_absolute*/ - (inquiry)long_bool, /*tp_bool*/ + long_bool, /*tp_bool*/ long_invert, /*nb_invert*/ long_lshift, /*nb_lshift*/ long_rshift, /*nb_rshift*/ From a9f4841a5ab6ed0a5d1fe8e0b5e166a3977cedc8 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 02:48:47 -0600 Subject: [PATCH 011/120] Update longobject.c Objects/longobject.c:6238:5: warning: cast from 'PyObject *(*)(PyLongObject *, PyLongObject *)' (aka 'struct _object *(*)(struct _longobject *, struct _longobject *)') to 'binaryfunc' (aka 'struct _object *(*)(struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 6238 | (binaryfunc)long_add, /*nb_add*/ | ^~~~~~~~~~~~~~~~~~~~ Objects/longobject.c:6239:5: warning: cast from 'PyObject *(*)(PyLongObject *, PyLongObject *)' (aka 'struct _object *(*)(struct _longobject *, struct _longobject *)') to 'binaryfunc' (aka 'struct _object *(*)(struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 6239 | (binaryfunc)long_sub, /*nb_subtract*/ | ^~~~~~~~~~~~~~~~~~~~ Objects/longobject.c:6240:5: warning: cast from 'PyObject *(*)(PyLongObject *, PyLongObject *)' (aka 'struct _object *(*)(struct _longobject *, struct _longobject *)') to 'binaryfunc' (aka 'struct _object *(*)(struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 6240 | (binaryfunc)long_mul, /*nb_multiply*/ | ^~~~~~~~~~~~~~~~~~~~ Example UBSan errors: Objects/abstract.c:949:13: runtime error: call to function long_add through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *)' longobject.c:3474: note: long_add defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:949:13 in Objects/abstract.c:949:13: runtime error: call to function long_sub through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *)' longobject.c:3510: note: long_sub defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:949:13 in Objects/abstract.c:957:23: runtime error: call to function long_mul through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *)' longobject.c:3953: note: long_mul defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:957:23 in --- Objects/longobject.c | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c index eb4abc415d8187..843f1f6f24d18d 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -6237,10 +6237,32 @@ Base 0 means to interpret the base from the string as an integer literal.\n\ >>> int('0b100', base=0)\n\ 4"); +static PyObject * +long_add_wrap(PyObject *o1, PyObject *o2) +{ + PyLongObject *a = (PyLongObject *)o1; + PyLongObject *b = (PyLongObject *)o2; + return long_add(a, b); +} +static PyObject * +long_sub_wrap(PyObject *o1, PyObject *o2) +{ + PyLongObject *a = (PyLongObject *)o1; + PyLongObject *b = (PyLongObject *)o2; + return long_sub(a, b); +} +static PyObject * +long_mul_wrap(PyObject *o1, PyObject *o2) +{ + PyLongObject *a = (PyLongObject *)o1; + PyLongObject *b = (PyLongObject *)o2; + return long_mul(a, b); +} + static PyNumberMethods long_as_number = { - (binaryfunc)long_add, /*nb_add*/ - (binaryfunc)long_sub, /*nb_subtract*/ - (binaryfunc)long_mul, /*nb_multiply*/ + long_add_wrap, /*nb_add*/ + long_sub_wrap, /*nb_subtract*/ + long_mul_wrap, /*nb_multiply*/ long_mod, /*nb_remainder*/ long_divmod, /*nb_divmod*/ long_pow, /*nb_power*/ From ad47ec3cbb2bb5794e5cc211e543d4d017e8504e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:22:39 -0600 Subject: [PATCH 012/120] Update tupleobject.c Objects/tupleobject.c:851:5: warning: cast from 'void (*)(PyTupleObject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 851 | (destructor)tupledealloc, /* tp_dealloc */ | ^~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Python/generated_cases.c.h:430:17: runtime error: call to function tupledealloc through pointer to incorrect function type 'void (*)(struct _object *)' tupleobject.c:187: note: tupledealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:430:17 in --- Objects/tupleobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index d567839c5e3a0b..cd80f682934a06 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -183,8 +183,9 @@ PyTuple_Pack(Py_ssize_t n, ...) /* Methods */ static void -tupledealloc(PyTupleObject *op) +tupledealloc(PyObject *obj) { + PyTupleObject *op = (PyTupleObject *)obj; if (Py_SIZE(op) == 0) { /* The empty tuple is statically allocated. */ if (op == &_Py_SINGLETON(tuple_empty)) { @@ -848,7 +849,7 @@ PyTypeObject PyTuple_Type = { "tuple", sizeof(PyTupleObject) - sizeof(PyObject *), sizeof(PyObject *), - (destructor)tupledealloc, /* tp_dealloc */ + tupledealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ From f8067403aa7084ccf0ebb6f5e3772254ed4da207 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:27:11 -0600 Subject: [PATCH 013/120] Update tupleobject.c Objects/tupleobject.c:1078:5: warning: cast from 'void (*)(_PyTupleIterObject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 1078 | (destructor)tupleiter_dealloc, /* tp_dealloc */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Python/generated_cases.c.h:2594:21: runtime error: call to function tupleiter_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' tupleobject.c:984: note: tupleiter_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:2594:21 in --- Objects/tupleobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index cd80f682934a06..cdb5aff12a91e8 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -981,8 +981,9 @@ _PyTuple_ClearFreeList(PyInterpreterState *interp) static void -tupleiter_dealloc(_PyTupleIterObject *it) +tupleiter_dealloc(PyObject *obj) { + _PyTupleIterObject *it = (_PyTupleIterObject *)obj; _PyObject_GC_UNTRACK(it); Py_XDECREF(it->it_seq); PyObject_GC_Del(it); @@ -1076,7 +1077,7 @@ PyTypeObject PyTupleIter_Type = { sizeof(_PyTupleIterObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)tupleiter_dealloc, /* tp_dealloc */ + tupleiter_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ From a16e825b26c0cb9ad186e5fd1ad901faf0014bcd Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:32:39 -0600 Subject: [PATCH 014/120] Update tupleobject.c Objects/tupleobject.c:1095:5: warning: cast from 'int (*)(_PyTupleIterObject *, visitproc, void *)' (aka 'int (*)(_PyTupleIterObject *, int (*)(struct _object *, void *), void *)') to 'traverseproc' (aka 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)') converts to incompatible function type [-Wcast-function-type-strict] 1095 | (traverseproc)tupleiter_traverse, /* tp_traverse */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ No example UBSan error --- Objects/tupleobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index cdb5aff12a91e8..7e12a5a30daa1e 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -990,8 +990,9 @@ tupleiter_dealloc(PyObject *obj) } static int -tupleiter_traverse(_PyTupleIterObject *it, visitproc visit, void *arg) +tupleiter_traverse(PyObject *obj, visitproc visit, void *arg) { + _PyTupleIterObject *it = (_PyTupleIterObject *)obj; Py_VISIT(it->it_seq); return 0; } @@ -1094,7 +1095,7 @@ PyTypeObject PyTupleIter_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ 0, /* tp_doc */ - (traverseproc)tupleiter_traverse, /* tp_traverse */ + tupleiter_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ From 4941893d23e6bef2e16dbcfa7c13ed641aeb7cd9 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:34:12 -0600 Subject: [PATCH 015/120] Update tupleobject.c Objects/tupleobject.c:1100:5: warning: cast from 'PyObject *(*)(_PyTupleIterObject *)' (aka 'struct _object *(*)(_PyTupleIterObject *)') to 'iternextfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 1100 | (iternextfunc)tupleiter_next, /* tp_iternext */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/abstract.c:2972:14: runtime error: call to function tupleiter_next through pointer to incorrect function type 'struct _object *(*)(struct _object *)' tupleobject.c:999: note: tupleiter_next defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:2972:14 in --- Objects/tupleobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 7e12a5a30daa1e..49d3f32462c2ba 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -998,8 +998,9 @@ tupleiter_traverse(PyObject *obj, visitproc visit, void *arg) } static PyObject * -tupleiter_next(_PyTupleIterObject *it) +tupleiter_next(PyObject *obj) { + _PyTupleIterObject *it = (_PyTupleIterObject *)obj; PyTupleObject *seq; PyObject *item; @@ -1100,7 +1101,7 @@ PyTypeObject PyTupleIter_Type = { 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ - (iternextfunc)tupleiter_next, /* tp_iternext */ + tupleiter_next, /* tp_iternext */ tupleiter_methods, /* tp_methods */ 0, }; From 5f4d942142a3804770dc13d74d8804bc6b3ef36a Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:41:22 -0600 Subject: [PATCH 016/120] Update listobject.c Objects/listobject.c:2928:5: warning: cast from 'int (*)(PyListObject *, Py_ssize_t, PyObject *)' (aka 'int (*)(PyListObject *, long, struct _object *)') to 'ssizeobjargproc' (aka 'int (*)(struct _object *, long, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 2928 | (ssizeobjargproc)list_ass_item, /* sq_ass_item */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/abstract.c:2032:19: runtime error: call to function list_ass_item through pointer to incorrect function type 'int (*)(struct _object *, long, struct _object *)' listobject.c:780: note: list_ass_item defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:2032:19 in --- Objects/listobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 6f5a7c4ee1acb0..05c7d697d600d5 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -779,8 +779,9 @@ list_inplace_repeat(PyListObject *self, Py_ssize_t n) } static int -list_ass_item(PyListObject *a, Py_ssize_t i, PyObject *v) +list_ass_item(PyObject *obj, Py_ssize_t i, PyObject *v) { + PyListObject *a = (PyListObject *)obj; if (!valid_index(i, Py_SIZE(a))) { PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); @@ -2929,7 +2930,7 @@ static PySequenceMethods list_as_sequence = { (ssizeargfunc)list_repeat, /* sq_repeat */ (ssizeargfunc)list_item, /* sq_item */ 0, /* sq_slice */ - (ssizeobjargproc)list_ass_item, /* sq_ass_item */ + list_ass_item, /* sq_ass_item */ 0, /* sq_ass_slice */ (objobjproc)list_contains, /* sq_contains */ (binaryfunc)list_inplace_concat, /* sq_inplace_concat */ @@ -2999,7 +3000,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) return -1; if (i < 0) i += PyList_GET_SIZE(self); - return list_ass_item(self, i, value); + return list_ass_item((PyObject *)self, i, value); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength; From 2a076d20b902869dd47bb0cc9691f796a4723fc6 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:45:02 -0600 Subject: [PATCH 017/120] Update bytesobject.c Objects/bytesobject.c:2952:5: warning: cast from 'PyObject *(*)(PyBytesObject *, PyBytesObject *, int)' (aka 'struct _object *(*)(PyBytesObject *, PyBytesObject *, int)') to 'richcmpfunc' (aka 'struct _object *(*)(struct _object *, struct _object *, int)') converts to incompatible function type [-Wcast-function-type-strict] 2952 | (richcmpfunc)bytes_richcompare, /* tp_richcompare */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:904:15: runtime error: call to function bytes_richcompare through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *, int)' bytesobject.c:1524: note: bytes_richcompare defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:904:15 in --- Objects/bytesobject.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 26227dd251122d..1d30cf5f8bd9c3 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -1520,8 +1520,10 @@ bytes_compare_eq(PyBytesObject *a, PyBytesObject *b) } static PyObject* -bytes_richcompare(PyBytesObject *a, PyBytesObject *b, int op) +bytes_richcompare(PyObject *o1, PyObject *o2, int op) { + PyBytesObject *a = (PyBytesObject *)o1; + PyBytesObject *b = (PyBytesObject *)o2; int c; Py_ssize_t len_a, len_b; Py_ssize_t min_len; @@ -2949,7 +2951,7 @@ PyTypeObject PyBytes_Type = { bytes_doc, /* tp_doc */ 0, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)bytes_richcompare, /* tp_richcompare */ + bytes_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ bytes_iter, /* tp_iter */ 0, /* tp_iternext */ From 8f6e37b90b447dbfc89c3d85692e1c19a79f1b87 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:52:16 -0600 Subject: [PATCH 018/120] Update listobject.c Objects/listobject.c:3251:5: warning: cast from 'PyObject *(*)(_PyListIterObject *)' (aka 'struct _object *(*)(_PyListIterObject *)') to 'iternextfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 3251 | (iternextfunc)listiter_next, /* tp_iternext */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/typeobject.c:8150:11: runtime error: call to function listiter_next through pointer to incorrect function type 'struct _object *(*)(struct _object *)' listobject.c:3292: note: listiter_next defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/typeobject.c:8150:11 in --- Objects/listobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 05c7d697d600d5..ab62a80a250958 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3208,7 +3208,7 @@ PyTypeObject PyList_Type = { static void listiter_dealloc(_PyListIterObject *); static int listiter_traverse(_PyListIterObject *, visitproc, void *); -static PyObject *listiter_next(_PyListIterObject *); +static PyObject *listiter_next(PyObject *); static PyObject *listiter_len(_PyListIterObject *, PyObject *); static PyObject *listiter_reduce_general(void *_it, int forward); static PyObject *listiter_reduce(_PyListIterObject *, PyObject *); @@ -3253,7 +3253,7 @@ PyTypeObject PyListIter_Type = { 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ - (iternextfunc)listiter_next, /* tp_iternext */ + listiter_next, /* tp_iternext */ listiter_methods, /* tp_methods */ 0, /* tp_members */ }; @@ -3293,8 +3293,9 @@ listiter_traverse(_PyListIterObject *it, visitproc visit, void *arg) } static PyObject * -listiter_next(_PyListIterObject *it) +listiter_next(PyObject *obj) { + _PyListIterObject *it = (_PyListIterObject *)obj; PyListObject *seq; PyObject *item; From 94e6206f1dc59e063eabe83d43797404dca14190 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:55:52 -0600 Subject: [PATCH 019/120] Update descrobject.c Objects/descrobject.c:1913:5: warning: cast from 'void (*)(mappingproxyobject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 1913 | (destructor)mappingproxy_dealloc, /* tp_dealloc */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Python/generated_cases.c.h:3315:13: runtime error: call to function mappingproxy_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' descrobject.c:1160: note: mappingproxy_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3315:13 in --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 57921b110591e5..ff9ba7b05e44fa 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1156,8 +1156,9 @@ static PyMethodDef mappingproxy_methods[] = { }; static void -mappingproxy_dealloc(mappingproxyobject *pp) +mappingproxy_dealloc(PyObject *obj) { + mappingproxyobject *pp = (mappingproxyobject *)obj; _PyObject_GC_UNTRACK(pp); Py_DECREF(pp->mapping); PyObject_GC_Del(pp); @@ -1910,7 +1911,7 @@ PyTypeObject PyDictProxy_Type = { sizeof(mappingproxyobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)mappingproxy_dealloc, /* tp_dealloc */ + mappingproxy_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ From 9dde8ed280d30155a5759ef305a9dc5e58eba57b Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:59:29 -0600 Subject: [PATCH 020/120] Update classobject.c Objects/classobject.c:326:19: warning: cast from 'void (*)(PyMethodObject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 326 | .tp_dealloc = (destructor)method_dealloc, | ^~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Python/generated_cases.c.h:89:13: runtime error: call to function method_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' classobject.c:236: note: method_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:89:13 in --- Objects/classobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/classobject.c b/Objects/classobject.c index 618d88894debbe..4884e9c4b95290 100644 --- a/Objects/classobject.c +++ b/Objects/classobject.c @@ -232,8 +232,9 @@ method_new_impl(PyTypeObject *type, PyObject *function, PyObject *instance) } static void -method_dealloc(PyMethodObject *im) +method_dealloc(PyObject *obj) { + PyMethodObject *im = (PyMethodObject *)obj; _PyObject_GC_UNTRACK(im); if (im->im_weakreflist != NULL) PyObject_ClearWeakRefs((PyObject *)im); @@ -323,7 +324,7 @@ PyTypeObject PyMethod_Type = { PyVarObject_HEAD_INIT(&PyType_Type, 0) .tp_name = "method", .tp_basicsize = sizeof(PyMethodObject), - .tp_dealloc = (destructor)method_dealloc, + .tp_dealloc = method_dealloc, .tp_vectorcall_offset = offsetof(PyMethodObject, vectorcall), .tp_repr = (reprfunc)method_repr, .tp_hash = (hashfunc)method_hash, From 480b9d94d2928b15e95dcf60fc3bed2ef03e18f8 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:12:27 -0600 Subject: [PATCH 021/120] Update descrobject.c Objects/descrobject.c:808:5: warning: cast from 'PyObject *(*)(PyMemberDescrObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(PyMemberDescrObject *, struct _object *, struct _object *)') to 'descrgetfunc' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 808 | (descrgetfunc)member_get, /* tp_descr_get */ | ^~~~~~~~~~~~~~~~~~~~~~~~ Objects/descrobject.c:809:5: warning: cast from 'int (*)(PyMemberDescrObject *, PyObject *, PyObject *)' (aka 'int (*)(PyMemberDescrObject *, struct _object *, struct _object *)') to 'descrsetfunc' (aka 'int (*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 809 | (descrsetfunc)member_set, /* tp_descr_set */ | ^~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:1682:19: runtime error: call to function member_set through pointer to incorrect function type 'int (*)(struct _object *, struct _object *, struct _object *)' descrobject.c:227: note: member_set defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:1682:19 in Objects/object.c:1564:19: runtime error: call to function member_get through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *, struct _object *)' descrobject.c:160: note: member_get defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:1564:19 in --- Objects/descrobject.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index ff9ba7b05e44fa..a838f4c4a718eb 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -156,8 +156,9 @@ method_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type) } static PyObject * -member_get(PyMemberDescrObject *descr, PyObject *obj, PyObject *type) +member_get(PyObject *self, PyObject *obj, PyObject *type) { + PyMemberDescrObject *descr = (PyMemberDescrObject *)self; if (obj == NULL) { return Py_NewRef(descr); } @@ -223,8 +224,9 @@ descr_setcheck(PyDescrObject *descr, PyObject *obj, PyObject *value) } static int -member_set(PyMemberDescrObject *descr, PyObject *obj, PyObject *value) +member_set(PyObject *self, PyObject *obj, PyObject *value) { + PyMemberDescrObject *descr = (PyMemberDescrObject *)self; if (descr_setcheck((PyDescrObject *)descr, obj, value) < 0) { return -1; } @@ -805,8 +807,8 @@ PyTypeObject PyMemberDescr_Type = { member_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ - (descrgetfunc)member_get, /* tp_descr_get */ - (descrsetfunc)member_set, /* tp_descr_set */ + member_get, /* tp_descr_get */ + member_set, /* tp_descr_set */ }; PyTypeObject PyGetSetDescr_Type = { From 569c65efad51deeb679f0690fcb6a14e643a6d4f Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:19:47 -0600 Subject: [PATCH 022/120] Update tupleobject.c Objects/tupleobject.c:860:5: warning: cast from 'Py_hash_t (*)(PyTupleObject *)' (aka 'long (*)(PyTupleObject *)') to 'hashfunc' (aka 'long (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 860 | (hashfunc)tuplehash, /* tp_hash */ | ^~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:999:16: runtime error: call to function tuplehash through pointer to incorrect function type 'long (*)(struct _object *)' tupleobject.c:323: note: tuplehash defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:999:16 in --- Objects/tupleobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index 49d3f32462c2ba..fcfa955700d0d0 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -319,8 +319,9 @@ tuplerepr(PyTupleObject *v) /* Tests have shown that it's not worth to cache the hash value, see https://bugs.python.org/issue9685 */ static Py_hash_t -tuplehash(PyTupleObject *v) +tuplehash(PyObject *obj) { + PyTupleObject *v = (PyTupleObject *)obj; Py_ssize_t i, len = Py_SIZE(v); PyObject **item = v->ob_item; @@ -858,7 +859,7 @@ PyTypeObject PyTuple_Type = { 0, /* tp_as_number */ &tuple_as_sequence, /* tp_as_sequence */ &tuple_as_mapping, /* tp_as_mapping */ - (hashfunc)tuplehash, /* tp_hash */ + tuplehash, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ From 767c89884331c44081e64a8723774a3119281c45 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:23:57 -0600 Subject: [PATCH 023/120] Update descrobject.c Example compiler warning: Objects/descrobject.c:703:5: warning: cast from 'void (*)(PyDescrObject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 703 | (destructor)descr_dealloc, /* tp_dealloc */ | ^~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:2857:5: runtime error: call to function descr_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' descrobject.c:23: note: descr_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:2857:5 in --- Objects/descrobject.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index a838f4c4a718eb..bb8b1c6bcb93f7 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -19,8 +19,9 @@ class property "propertyobject *" "&PyProperty_Type" /*[clinic end generated code: output=da39a3ee5e6b4b0d input=556352653fd4c02e]*/ static void -descr_dealloc(PyDescrObject *descr) +descr_dealloc(PyObject *obj) { + PyDescrObject *descr = (PyDescrObject *)obj; _PyObject_GC_UNTRACK(descr); Py_XDECREF(descr->d_type); Py_XDECREF(descr->d_name); @@ -702,7 +703,7 @@ PyTypeObject PyMethodDescr_Type = { "method_descriptor", sizeof(PyMethodDescrObject), 0, - (destructor)descr_dealloc, /* tp_dealloc */ + descr_dealloc, /* tp_dealloc */ offsetof(PyMethodDescrObject, vectorcall), /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -742,7 +743,7 @@ PyTypeObject PyClassMethodDescr_Type = { "classmethod_descriptor", sizeof(PyMethodDescrObject), 0, - (destructor)descr_dealloc, /* tp_dealloc */ + descr_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -779,7 +780,7 @@ PyTypeObject PyMemberDescr_Type = { "member_descriptor", sizeof(PyMemberDescrObject), 0, - (destructor)descr_dealloc, /* tp_dealloc */ + descr_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -816,7 +817,7 @@ PyTypeObject PyGetSetDescr_Type = { "getset_descriptor", sizeof(PyGetSetDescrObject), 0, - (destructor)descr_dealloc, /* tp_dealloc */ + descr_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -853,7 +854,7 @@ PyTypeObject PyWrapperDescr_Type = { "wrapper_descriptor", sizeof(PyWrapperDescrObject), 0, - (destructor)descr_dealloc, /* tp_dealloc */ + descr_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ From 3c0a1548d32aaefd7edf939777b45701d975b9fb Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:30:33 -0600 Subject: [PATCH 024/120] Update descrobject.c Objects/descrobject.c:771:5: warning: cast from 'PyObject *(*)(PyMethodDescrObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(PyMethodDescrObject *, struct _object *, struct _object *)') to 'descrgetfunc' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 771 | (descrgetfunc)classmethod_get, /* tp_descr_get */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/typeobject.c:10293:24: runtime error: call to function classmethod_get through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *, struct _object *)' descrobject.c:94: note: classmethod_get defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/typeobject.c:10293:24 in --- Objects/descrobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index bb8b1c6bcb93f7..cffe3983097168 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -91,8 +91,9 @@ descr_check(PyDescrObject *descr, PyObject *obj) } static PyObject * -classmethod_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type) +classmethod_get(PyObject *self, PyObject *obj, PyObject *type) { + PyMethodDescrObject *descr = (PyMethodDescrObject *)self; /* Ensure a valid type. Class methods ignore obj. */ if (type == NULL) { if (obj != NULL) @@ -495,7 +496,7 @@ classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, return NULL; } PyObject *self = PyTuple_GET_ITEM(args, 0); - PyObject *bound = classmethod_get(descr, NULL, self); + PyObject *bound = classmethod_get((PyObject *)descr, NULL, self); if (bound == NULL) { return NULL; } @@ -771,7 +772,7 @@ PyTypeObject PyClassMethodDescr_Type = { method_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ - (descrgetfunc)classmethod_get, /* tp_descr_get */ + classmethod_get, /* tp_descr_get */ 0, /* tp_descr_set */ }; From 45e69e32fe033d9ec6164e40607ee3720f887cbf Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:45:12 -0600 Subject: [PATCH 025/120] Update bytesobject.c Objects/bytesobject.c:1686:5: warning: cast from 'int (*)(PyBytesObject *, Py_buffer *, int)' to 'getbufferproc' (aka 'int (*)(struct _object *, Py_buffer *, int)') converts to incompatible function type [-Wcast-function-type-strict] 1686 | (getbufferproc)bytes_buffer_getbuffer, | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/abstract.c:436:15: runtime error: call to function bytes_buffer_getbuffer through pointer to incorrect function type 'int (*)(struct _object *, Py_buffer *, int)' bytesobject.c:1665: note: bytes_buffer_getbuffer defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:436:15 in --- Objects/bytesobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 1d30cf5f8bd9c3..138744b0b7b9b6 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -1661,8 +1661,9 @@ bytes_subscript(PyBytesObject* self, PyObject* item) } static int -bytes_buffer_getbuffer(PyBytesObject *self, Py_buffer *view, int flags) +bytes_buffer_getbuffer(PyObject *obj, Py_buffer *view, int flags) { + PyBytesObject *self = (PyBytesObject *)obj; return PyBuffer_FillInfo(view, (PyObject*)self, (void *)self->ob_sval, Py_SIZE(self), 1, flags); } @@ -1685,7 +1686,7 @@ static PyMappingMethods bytes_as_mapping = { }; static PyBufferProcs bytes_as_buffer = { - (getbufferproc)bytes_buffer_getbuffer, + bytes_buffer_getbuffer, NULL, }; From ba8519b030826b6387a24e6a4f00f5199a0aadf8 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:53:16 -0600 Subject: [PATCH 026/120] Update bytesobject.c Objects/bytesobject.c:2940:5: warning: cast from 'Py_hash_t (*)(PyBytesObject *)' (aka 'long (*)(PyBytesObject *)') to 'hashfunc' (aka 'long (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 2940 | (hashfunc)bytes_hash, /* tp_hash */ | ^~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:999:16: runtime error: call to function bytes_hash through pointer to incorrect function type 'long (*)(struct _object *)' bytesobject.c:1587: note: bytes_hash defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:999:16 in --- Objects/bytesobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/bytesobject.c b/Objects/bytesobject.c index 138744b0b7b9b6..36e898e88f3f9e 100644 --- a/Objects/bytesobject.c +++ b/Objects/bytesobject.c @@ -1583,8 +1583,9 @@ bytes_richcompare(PyObject *o1, PyObject *o2, int op) } static Py_hash_t -bytes_hash(PyBytesObject *a) +bytes_hash(PyObject *obj) { + PyBytesObject *a = (PyBytesObject *)obj; _Py_COMP_DIAG_PUSH _Py_COMP_DIAG_IGNORE_DEPR_DECLS if (a->ob_shash == -1) { @@ -2940,7 +2941,7 @@ PyTypeObject PyBytes_Type = { &bytes_as_number, /* tp_as_number */ &bytes_as_sequence, /* tp_as_sequence */ &bytes_as_mapping, /* tp_as_mapping */ - (hashfunc)bytes_hash, /* tp_hash */ + bytes_hash, /* tp_hash */ 0, /* tp_call */ bytes_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ From 7ce96df656f4b4f96bedee91d552c0dab78992c7 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:57:27 -0600 Subject: [PATCH 027/120] Update tupleobject.c Objects/tupleobject.c:755:5: warning: cast from 'PyObject *(*)(PyTupleObject *, PyObject *)' (aka 'struct _object *(*)(PyTupleObject *, struct _object *)') to 'binaryfunc' (aka 'struct _object *(*)(struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 755 | (binaryfunc)tupleconcat, /* sq_concat */ | ^~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/abstract.c:1137:18: runtime error: call to function tupleconcat through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *)' tupleobject.c:443: note: tupleconcat defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:1137:18 in --- Objects/tupleobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index fcfa955700d0d0..1ddcfff6ba8862 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -441,8 +441,9 @@ PyTuple_GetSlice(PyObject *op, Py_ssize_t i, Py_ssize_t j) } static PyObject * -tupleconcat(PyTupleObject *a, PyObject *bb) +tupleconcat(PyObject *aa, PyObject *bb) { + PyTupleObject *a = (PyTupleObject *)aa; Py_ssize_t size; Py_ssize_t i; PyObject **src, **dest; @@ -754,7 +755,7 @@ tuple_subtype_new(PyTypeObject *type, PyObject *iterable) static PySequenceMethods tuple_as_sequence = { (lenfunc)tuplelength, /* sq_length */ - (binaryfunc)tupleconcat, /* sq_concat */ + tupleconcat, /* sq_concat */ (ssizeargfunc)tuplerepeat, /* sq_repeat */ (ssizeargfunc)tupleitem, /* sq_item */ 0, /* sq_slice */ From 9fe219b19cbfe2d2adf654adf3fbe8656de55674 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 05:04:15 -0600 Subject: [PATCH 028/120] Update listobject.c Objects/listobject.c:2923:5: warning: cast from 'Py_ssize_t (*)(PyListObject *)' (aka 'long (*)(PyListObject *)') to 'lenfunc' (aka 'long (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 2923 | (lenfunc)list_length, /* sq_length */ | ^~~~~~~~~~~~~~~~~~~~ Objects/listobject.c:3152:5: warning: cast from 'Py_ssize_t (*)(PyListObject *)' (aka 'long (*)(PyListObject *)') to 'lenfunc' (aka 'long (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 3152 | (lenfunc)list_length, | ^~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:1820:15: runtime error: call to function list_length through pointer to incorrect function type 'long (*)(struct _object *)' listobject.c:438: note: list_length defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:1820:15 in --- Objects/listobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index ab62a80a250958..eac7d154783577 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -436,7 +436,7 @@ list_repr(PyObject *obj) } static Py_ssize_t -list_length(PyListObject *a) +list_length(PyObject *a) { return Py_SIZE(a); } @@ -2925,7 +2925,7 @@ static PyMethodDef list_methods[] = { }; static PySequenceMethods list_as_sequence = { - (lenfunc)list_length, /* sq_length */ + list_length, /* sq_length */ (binaryfunc)list_concat, /* sq_concat */ (ssizeargfunc)list_repeat, /* sq_repeat */ (ssizeargfunc)list_item, /* sq_item */ @@ -3154,7 +3154,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) } static PyMappingMethods list_as_mapping = { - (lenfunc)list_length, + list_length, (binaryfunc)list_subscript, (objobjargproc)list_ass_subscript }; From 914bcc2aadba935f3c20c9a9bb7e562cd5a1df6d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 21:15:28 -0600 Subject: [PATCH 029/120] Update descrobject.c Objects/descrobject.c:845:5: warning: cast from 'PyObject *(*)(PyGetSetDescrObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(PyGetSetDescrObject *, struct _object *, struct _object *)') to 'descrgetfunc' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 845 | (descrgetfunc)getset_get, /* tp_descr_get */ | ^~~~~~~~~~~~~~~~~~~~~~~~ Objects/descrobject.c:846:5: warning: cast from 'int (*)(PyGetSetDescrObject *, PyObject *, PyObject *)' (aka 'int (*)(PyGetSetDescrObject *, struct _object *, struct _object *)') to 'descrsetfunc' (aka 'int (*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 846 | (descrsetfunc)getset_set, /* tp_descr_set */ | ^~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/typeobject.c:4861:19: runtime error: call to function getset_get through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *, struct _object *)' descrobject.c:180: note: getset_get defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/typeobject.c:4861:19 in --- Objects/descrobject.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index cffe3983097168..8b973205e52414 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -179,8 +179,9 @@ member_get(PyObject *self, PyObject *obj, PyObject *type) } static PyObject * -getset_get(PyGetSetDescrObject *descr, PyObject *obj, PyObject *type) +getset_get(PyObject *self, PyObject *obj, PyObject *type) { + PyGetSetDescrObject *descr = (PyGetSetDescrObject *)self; if (obj == NULL) { return Py_NewRef(descr); } @@ -236,8 +237,9 @@ member_set(PyObject *self, PyObject *obj, PyObject *value) } static int -getset_set(PyGetSetDescrObject *descr, PyObject *obj, PyObject *value) +getset_set(PyObject *self, PyObject *obj, PyObject *value) { + PyGetSetDescrObject *descr = (PyGetSetDescrObject *)self; if (descr_setcheck((PyDescrObject *)descr, obj, value) < 0) { return -1; } @@ -846,8 +848,8 @@ PyTypeObject PyGetSetDescr_Type = { getset_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ - (descrgetfunc)getset_get, /* tp_descr_get */ - (descrsetfunc)getset_set, /* tp_descr_set */ + getset_get, /* tp_descr_get */ + getset_set, /* tp_descr_set */ }; PyTypeObject PyWrapperDescr_Type = { From 3d19a08b2bba2f40512825b98ffe30db0a65eb96 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 21:29:24 -0600 Subject: [PATCH 030/120] Update listobject.c Objects/listobject.c:3229:5: warning: cast from 'void (*)(_PyListIterObject *)' to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 3229 | (destructor)listiter_dealloc, /* tp_dealloc */ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Python/generated_cases.c.h:3322:21: runtime error: call to function listiter_dealloc through pointer to incorrect function type 'void (*)(struct _object *)' listobject.c:3222: note: listiter_dealloc defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Python/generated_cases.c.h:3322:21 in --- Objects/listobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index eac7d154783577..989d2a04ca1ba1 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3206,7 +3206,7 @@ PyTypeObject PyList_Type = { /*********************** List Iterator **************************/ -static void listiter_dealloc(_PyListIterObject *); +static void listiter_dealloc(PyObject *); static int listiter_traverse(_PyListIterObject *, visitproc, void *); static PyObject *listiter_next(PyObject *); static PyObject *listiter_len(_PyListIterObject *, PyObject *); @@ -3231,7 +3231,7 @@ PyTypeObject PyListIter_Type = { sizeof(_PyListIterObject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)listiter_dealloc, /* tp_dealloc */ + listiter_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -3278,8 +3278,9 @@ list_iter(PyObject *seq) } static void -listiter_dealloc(_PyListIterObject *it) +listiter_dealloc(PyObject *obj) { + _PyListIterObject *it = (_PyListIterObject *)obj; _PyObject_GC_UNTRACK(it); Py_XDECREF(it->it_seq); PyObject_GC_Del(it); From f643f56ebd98a04837b072d8e1f209be081a9c12 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 21:53:40 -0600 Subject: [PATCH 031/120] Update listobject.c Objects/listobject.c:2924:5: warning: cast from 'PyObject *(*)(PyListObject *, PyObject *)' (aka 'struct _object *(*)(PyListObject *, struct _object *)') to 'binaryfunc' (aka 'struct _object *(*)(struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 2924 | (binaryfunc)list_concat, /* sq_concat */ | ^~~~~~~~~~~~~~~~~~~~~~~ Objects/listobject.c:2925:5: warning: cast from 'PyObject *(*)(PyListObject *, Py_ssize_t)' (aka 'struct _object *(*)(PyListObject *, long)') to 'ssizeargfunc' (aka 'struct _object *(*)(struct _object *, long)') converts to incompatible function type [-Wcast-function-type-strict] 2925 | (ssizeargfunc)list_repeat, /* sq_repeat */ | ^~~~~~~~~~~~~~~~~~~~~~~~~ Objects/listobject.c:2926:5: warning: cast from 'PyObject *(*)(PyListObject *, Py_ssize_t)' (aka 'struct _object *(*)(PyListObject *, long)') to 'ssizeargfunc' (aka 'struct _object *(*)(struct _object *, long)') converts to incompatible function type [-Wcast-function-type-strict] 2926 | (ssizeargfunc)list_item, /* sq_item */ | ^~~~~~~~~~~~~~~~~~~~~~~ Example UBSan errors: Objects/abstract.c:1137:18: runtime error: call to function list_concat through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *)' listobject.c:518: note: list_concat defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:1137:18 in Objects/abstract.c:1159:21: runtime error: call to function list_repeat through pointer to incorrect function type 'struct _object *(*)(struct _object *, long)' listobject.c:558: note: list_repeat defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:1159:21 in Objects/abstract.c:1946:25: runtime error: call to function list_item through pointer to incorrect function type 'struct _object *(*)(struct _object *, long)' listobject.c:462: note: list_item defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:1946:25 in --- Objects/listobject.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 989d2a04ca1ba1..4db586526a614e 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -458,8 +458,9 @@ list_contains(PyListObject *a, PyObject *el) } static PyObject * -list_item(PyListObject *a, Py_ssize_t i) +list_item(PyObject *aa, Py_ssize_t i) { + PyListObject *a = (PyListObject *)aa; if (!valid_index(i, Py_SIZE(a))) { PyErr_SetObject(PyExc_IndexError, &_Py_STR(list_err)); return NULL; @@ -514,8 +515,9 @@ PyList_GetSlice(PyObject *a, Py_ssize_t ilow, Py_ssize_t ihigh) } static PyObject * -list_concat(PyListObject *a, PyObject *bb) +list_concat(PyObject *aa, PyObject *bb) { + PyListObject *a = (PyListObject *)aa; Py_ssize_t size; Py_ssize_t i; PyObject **src, **dest; @@ -554,8 +556,9 @@ list_concat(PyListObject *a, PyObject *bb) } static PyObject * -list_repeat(PyListObject *a, Py_ssize_t n) +list_repeat(PyObject *aa, Py_ssize_t n) { + PyListObject *a = (PyListObject *)aa; const Py_ssize_t input_size = Py_SIZE(a); if (input_size == 0 || n <= 0) return PyList_New(0); @@ -2926,9 +2929,9 @@ static PyMethodDef list_methods[] = { static PySequenceMethods list_as_sequence = { list_length, /* sq_length */ - (binaryfunc)list_concat, /* sq_concat */ - (ssizeargfunc)list_repeat, /* sq_repeat */ - (ssizeargfunc)list_item, /* sq_item */ + list_concat, /* sq_concat */ + list_repeat, /* sq_repeat */ + list_item, /* sq_item */ 0, /* sq_slice */ list_ass_item, /* sq_ass_item */ 0, /* sq_ass_slice */ From 369ed558cd9a1efbe74db7fb5b4cc712f3f2ed3b Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 22:07:01 -0600 Subject: [PATCH 032/120] Update descrobject.c Objects/descrobject.c:739:5: warning: cast from 'PyObject *(*)(PyMethodDescrObject *, PyObject *, PyObject *)' (aka 'struct _object *(*)(PyMethodDescrObject *, struct _object *, struct _object *)') to 'descrgetfunc' (aka 'struct _object *(*)(struct _object *, struct _object *, struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 739 | (descrgetfunc)method_get, /* tp_descr_get */ | ^~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/object.c:1621:15: runtime error: call to function method_get through pointer to incorrect function type 'struct _object *(*)(struct _object *, struct _object *, struct _object *)' descrobject.c:138: note: method_get defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:1621:15 in --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 8b973205e52414..d0fb714dbeac78 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -134,8 +134,9 @@ classmethod_get(PyObject *self, PyObject *obj, PyObject *type) } static PyObject * -method_get(PyMethodDescrObject *descr, PyObject *obj, PyObject *type) +method_get(PyObject *self, PyObject *obj, PyObject *type) { + PyMethodDescrObject *descr = (PyMethodDescrObject *)self; if (obj == NULL) { return Py_NewRef(descr); } @@ -736,7 +737,7 @@ PyTypeObject PyMethodDescr_Type = { method_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ - (descrgetfunc)method_get, /* tp_descr_get */ + method_get, /* tp_descr_get */ 0, /* tp_descr_set */ }; From 08413662330c2e644b16b4169c36cdc8a68e945a Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 22:11:17 -0600 Subject: [PATCH 033/120] Update _pickle.c ./Modules/_pickle.c:7973:15: warning: cast from 'void (*)(PyObject *)' (aka 'void (*)(struct _object *)') to 'freefunc' (aka 'void (*)(void *)') converts to incompatible function type [-Wcast-function-type-strict] 7973 | .m_free = (freefunc)pickle_free, | ^~~~~~~~~~~~~~~~~~~~~ Example UBSan error: Objects/moduleobject.c:735:9: runtime error: call to function pickle_free through pointer to incorrect function type 'void (*)(void *)' _pickle.c:7867: note: pickle_free defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/moduleobject.c:735:9 in --- Modules/_pickle.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Modules/_pickle.c b/Modules/_pickle.c index 227e5378e42285..408214b30840c7 100644 --- a/Modules/_pickle.c +++ b/Modules/_pickle.c @@ -7863,8 +7863,9 @@ pickle_clear(PyObject *m) } static void -pickle_free(PyObject *m) +pickle_free(void *ptr) { + PyObject *m = ptr; _Pickle_ClearState(_Pickle_GetState(m)); } @@ -7970,7 +7971,7 @@ static struct PyModuleDef _picklemodule = { .m_slots = pickle_slots, .m_traverse = pickle_traverse, .m_clear = pickle_clear, - .m_free = (freefunc)pickle_free, + .m_free = pickle_free, }; PyMODINIT_FUNC From cdce5fddfd89fee283d2da59591dd6fa5a09bd58 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 23:27:57 -0600 Subject: [PATCH 034/120] Update floatobject.c Objects/floatobject.c:1858:5: warning: cast from 'PyObject *(*)(PyFloatObject *)' (aka 'struct _object *(*)(PyFloatObject *)') to 'unaryfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 1858 | (unaryfunc)float_neg, /* nb_negative */ | ^~~~~~~~~~~~~~~~~~~~ Objects/floatobject.c:1860:5: warning: cast from 'PyObject *(*)(PyFloatObject *)' (aka 'struct _object *(*)(PyFloatObject *)') to 'unaryfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 1860 | (unaryfunc)float_abs, /* nb_absolute */ | ^~~~~~~~~~~~~~~~~~~~ Objects/floatobject.c:1861:5: warning: cast from 'int (*)(PyFloatObject *)' to 'inquiry' (aka 'int (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 1861 | (inquiry)float_bool, /* nb_bool */ | ^~~~~~~~~~~~~~~~~~~ Objects/floatobject.c:1897:5: warning: cast from 'PyObject *(*)(PyFloatObject *)' (aka 'struct _object *(*)(PyFloatObject *)') to 'reprfunc' (aka 'struct _object *(*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 1897 | (reprfunc)float_repr, /* tp_repr */ | ^~~~~~~~~~~~~~~~~~~~ Example UBSan errors: Objects/abstract.c:1391:25: runtime error: call to function float_neg through pointer to incorrect function type 'struct _object *(*)(struct _object *)' floatobject.c:864: note: float_neg defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:1391:25 in Objects/abstract.c:1442:25: runtime error: call to function float_abs through pointer to incorrect function type 'struct _object *(*)(struct _object *)' floatobject.c:870: note: float_abs defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/abstract.c:1442:25 in Objects/object.c:1817:15: runtime error: call to function float_bool through pointer to incorrect function type 'int (*)(struct _object *)' floatobject.c:876: note: float_bool defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:1817:15 in Objects/typeobject.c:7850:12: runtime error: call to function float_repr through pointer to incorrect function type 'struct _object *(*)(struct _object *)' floatobject.c:383: note: float_repr defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/typeobject.c:7850:12 in --- Objects/floatobject.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 364cf1553bb5d4..32e153b21d3a14 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -379,8 +379,9 @@ convert_to_double(PyObject **v, double *dbl) } static PyObject * -float_repr(PyFloatObject *v) +float_repr(PyObject *obj) { + PyFloatObject *v = (PyFloatObject *)obj; PyObject *result; char *buf; @@ -860,20 +861,23 @@ float_pow(PyObject *v, PyObject *w, PyObject *z) #undef DOUBLE_IS_ODD_INTEGER static PyObject * -float_neg(PyFloatObject *v) +float_neg(PyObject *obj) { + PyFloatObject *v = (PyFloatObject *)obj; return PyFloat_FromDouble(-v->ob_fval); } static PyObject * -float_abs(PyFloatObject *v) +float_abs(PyObject *obj) { + PyFloatObject *v = (PyFloatObject *)obj; return PyFloat_FromDouble(fabs(v->ob_fval)); } static int -float_bool(PyFloatObject *v) +float_bool(PyObject *obj) { + PyFloatObject *v = (PyFloatObject *)obj; return v->ob_fval != 0.0; } @@ -1245,7 +1249,7 @@ float_hex_impl(PyObject *self) CONVERT_TO_DOUBLE(self, x); if (Py_IS_NAN(x) || Py_IS_INFINITY(x)) - return float_repr((PyFloatObject *)self); + return float_repr(self); if (x == 0.0) { if (copysign(1.0, x) == -1.0) @@ -1855,10 +1859,10 @@ static PyNumberMethods float_as_number = { float_rem, /* nb_remainder */ float_divmod, /* nb_divmod */ float_pow, /* nb_power */ - (unaryfunc)float_neg, /* nb_negative */ + float_neg, /* nb_negative */ float_float, /* nb_positive */ - (unaryfunc)float_abs, /* nb_absolute */ - (inquiry)float_bool, /* nb_bool */ + float_abs, /* nb_absolute */ + float_bool, /* nb_bool */ 0, /* nb_invert */ 0, /* nb_lshift */ 0, /* nb_rshift */ @@ -1894,7 +1898,7 @@ PyTypeObject PyFloat_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)float_repr, /* tp_repr */ + float_repr, /* tp_repr */ &float_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ From 52a9592d6dd92037741aabdec5b0830ccee7a1ad Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Tue, 5 Dec 2023 02:06:54 -0600 Subject: [PATCH 035/120] Update weakrefobject.c Objects/weakrefobject.c:374:16: warning: cast from 'Py_hash_t (*)(PyWeakReference *)' (aka 'long (*)(struct _PyWeakReference *)') to 'hashfunc' (aka 'long (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 374 | .tp_hash = (hashfunc)weakref_hash, | ^~~~~~~~~~~~~~~~~~~~~~ Objects/weakrefobject.c:377:20: warning: cast from 'int (*)(PyWeakReference *, visitproc, void *)' (aka 'int (*)(struct _PyWeakReference *, int (*)(struct _object *, void *), void *)') to 'traverseproc' (aka 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)') converts to incompatible function type [-Wcast-function-type-strict] 377 | .tp_traverse = (traverseproc)gc_traverse, | ^~~~~~~~~~~~~~~~~~~~~~~~~ Example UBSan errors: Modules/gcmodule.c:605:20: runtime error: call to function gc_traverse through pointer to incorrect function type 'int (*)(struct _object *, int (*)(struct _object *, void *), void *)' weakrefobject.c:120: note: gc_traverse defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Modules/gcmodule.c:605:20 in Objects/object.c:999:16: runtime error: call to function weakref_hash through pointer to incorrect function type 'long (*)(struct _object *)' weakrefobject.c:154: note: weakref_hash defined here SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior Objects/object.c:999:16 in --- Objects/weakrefobject.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index df74be6aba7244..1ac8a4efde9df4 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -116,9 +116,9 @@ weakref_dealloc(PyObject *self) static int -gc_traverse(PyWeakReference *self, visitproc visit, void *arg) +gc_traverse(PyObject *self, visitproc visit, void *arg) { - Py_VISIT(self->wr_callback); + Py_VISIT(((PyWeakReference *)self)->wr_callback); return 0; } @@ -150,8 +150,9 @@ weakref_vectorcall(PyObject *self, PyObject *const *args, } static Py_hash_t -weakref_hash(PyWeakReference *self) +weakref_hash(PyObject *arg) { + PyWeakReference *self = (PyWeakReference *)arg; if (self->hash != -1) return self->hash; PyObject* obj = _PyWeakref_GET_REF((PyObject*)self); @@ -371,10 +372,10 @@ _PyWeakref_RefType = { .tp_vectorcall_offset = offsetof(PyWeakReference, vectorcall), .tp_call = PyVectorcall_Call, .tp_repr = weakref_repr, - .tp_hash = (hashfunc)weakref_hash, + .tp_hash = weakref_hash, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_VECTORCALL | Py_TPFLAGS_BASETYPE, - .tp_traverse = (traverseproc)gc_traverse, + .tp_traverse = gc_traverse, .tp_clear = (inquiry)gc_clear, .tp_richcompare = weakref_richcompare, .tp_methods = weakref_methods, @@ -734,7 +735,7 @@ _PyWeakref_ProxyType = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ 0, /* tp_doc */ - (traverseproc)gc_traverse, /* tp_traverse */ + gc_traverse, /* tp_traverse */ (inquiry)gc_clear, /* tp_clear */ proxy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ @@ -768,7 +769,7 @@ _PyWeakref_CallableProxyType = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ 0, /* tp_doc */ - (traverseproc)gc_traverse, /* tp_traverse */ + gc_traverse, /* tp_traverse */ (inquiry)gc_clear, /* tp_clear */ proxy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ From 363f891c0057ecc237c008335643ff8609205f03 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Tue, 5 Dec 2023 02:11:09 -0600 Subject: [PATCH 036/120] Update weakrefobject.c Objects/weakrefobject.c:378:17: warning: cast from 'int (*)(PyWeakReference *)' (aka 'int (*)(struct _PyWeakReference *)') to 'inquiry' (aka 'int (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 378 | .tp_clear = (inquiry)gc_clear, | ^~~~~~~~~~~~~~~~~ Objects/weakrefobject.c:719:5: warning: cast from 'void (*)(PyWeakReference *)' (aka 'void (*)(struct _PyWeakReference *)') to 'destructor' (aka 'void (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 719 | (destructor)proxy_dealloc, /* tp_dealloc */ | ^~~~~~~~~~~~~~~~~~~~~~~~~ No example UBSan errors. --- Objects/weakrefobject.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/Objects/weakrefobject.c b/Objects/weakrefobject.c index 1ac8a4efde9df4..5e3b7c3fd24428 100644 --- a/Objects/weakrefobject.c +++ b/Objects/weakrefobject.c @@ -124,9 +124,9 @@ gc_traverse(PyObject *self, visitproc visit, void *arg) static int -gc_clear(PyWeakReference *self) +gc_clear(PyObject *self) { - clear_weakref(self); + clear_weakref((PyWeakReference *)self); return 0; } @@ -376,7 +376,7 @@ _PyWeakref_RefType = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_VECTORCALL | Py_TPFLAGS_BASETYPE, .tp_traverse = gc_traverse, - .tp_clear = (inquiry)gc_clear, + .tp_clear = gc_clear, .tp_richcompare = weakref_richcompare, .tp_methods = weakref_methods, .tp_members = weakref_members, @@ -552,8 +552,9 @@ proxy_bool(PyObject *proxy) } static void -proxy_dealloc(PyWeakReference *self) +proxy_dealloc(PyObject *arg) { + PyWeakReference *self = (PyWeakReference *)arg; PyObject_GC_UnTrack(self); if (self->wr_callback != NULL) PyObject_GC_UnTrack((PyObject *)self); @@ -717,7 +718,7 @@ _PyWeakref_ProxyType = { sizeof(PyWeakReference), 0, /* methods */ - (destructor)proxy_dealloc, /* tp_dealloc */ + proxy_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -736,7 +737,7 @@ _PyWeakref_ProxyType = { Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ 0, /* tp_doc */ gc_traverse, /* tp_traverse */ - (inquiry)gc_clear, /* tp_clear */ + gc_clear, /* tp_clear */ proxy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ proxy_iter, /* tp_iter */ @@ -752,7 +753,7 @@ _PyWeakref_CallableProxyType = { sizeof(PyWeakReference), 0, /* methods */ - (destructor)proxy_dealloc, /* tp_dealloc */ + proxy_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -770,7 +771,7 @@ _PyWeakref_CallableProxyType = { Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ 0, /* tp_doc */ gc_traverse, /* tp_traverse */ - (inquiry)gc_clear, /* tp_clear */ + gc_clear, /* tp_clear */ proxy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ proxy_iter, /* tp_iter */ From 4af78532d69d9303461bf863ec00e952453c76f3 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Tue, 5 Dec 2023 02:15:05 -0600 Subject: [PATCH 037/120] Update floatobject.c Objects/floatobject.c:1901:5: warning: cast from 'Py_hash_t (*)(PyFloatObject *)' (aka 'long (*)(PyFloatObject *)') to 'hashfunc' (aka 'long (*)(struct _object *)') converts to incompatible function type [-Wcast-function-type-strict] 1901 | (hashfunc)float_hash, /* tp_hash */ | ^~~~~~~~~~~~~~~~~~~~ No example UBSan errors. --- Objects/floatobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/floatobject.c b/Objects/floatobject.c index 32e153b21d3a14..02b2c5269785b7 100644 --- a/Objects/floatobject.c +++ b/Objects/floatobject.c @@ -588,9 +588,9 @@ float_richcompare(PyObject *v, PyObject *w, int op) } static Py_hash_t -float_hash(PyFloatObject *v) +float_hash(PyObject *v) { - return _Py_HashDouble((PyObject *)v, v->ob_fval); + return _Py_HashDouble(v, ((PyFloatObject *)v)->ob_fval); } static PyObject * @@ -1902,7 +1902,7 @@ PyTypeObject PyFloat_Type = { &float_as_number, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - (hashfunc)float_hash, /* tp_hash */ + float_hash, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ From fd10bb9d7df4586f8db421f476289ef1b6aab1a3 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Tue, 5 Dec 2023 04:26:43 -0600 Subject: [PATCH 038/120] Make _Py_module_getattro() compatible with getattrofunc --- Include/internal/pycore_moduleobject.h | 2 +- Objects/moduleobject.c | 6 +++--- Objects/object.c | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/Include/internal/pycore_moduleobject.h b/Include/internal/pycore_moduleobject.h index 5644bbe5e0552b..d64fe3d634b18b 100644 --- a/Include/internal/pycore_moduleobject.h +++ b/Include/internal/pycore_moduleobject.h @@ -43,7 +43,7 @@ static inline PyObject* _PyModule_GetDict(PyObject *mod) { } PyObject* _Py_module_getattro_impl(PyModuleObject *m, PyObject *name, int suppress); -PyObject* _Py_module_getattro(PyModuleObject *m, PyObject *name); +PyObject* _Py_module_getattro(PyObject *m, PyObject *name); #ifdef __cplusplus } diff --git a/Objects/moduleobject.c b/Objects/moduleobject.c index bba77ce8ab7e7b..38a7fd85036da7 100644 --- a/Objects/moduleobject.c +++ b/Objects/moduleobject.c @@ -873,9 +873,9 @@ _Py_module_getattro_impl(PyModuleObject *m, PyObject *name, int suppress) PyObject* -_Py_module_getattro(PyModuleObject *m, PyObject *name) +_Py_module_getattro(PyObject *m, PyObject *name) { - return _Py_module_getattro_impl(m, name, 0); + return _Py_module_getattro_impl((PyModuleObject *)m, name, 0); } static int @@ -1025,7 +1025,7 @@ PyTypeObject PyModule_Type = { 0, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ - (getattrofunc)_Py_module_getattro, /* tp_getattro */ + _Py_module_getattro, /* tp_getattro */ PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | diff --git a/Objects/object.c b/Objects/object.c index d145674cb3ba34..e027529065ff8e 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -1204,7 +1204,7 @@ PyObject_GetOptionalAttr(PyObject *v, PyObject *name, PyObject **result) return 0; } } - else if (tp->tp_getattro == (getattrofunc)_Py_module_getattro) { + else if (tp->tp_getattro == _Py_module_getattro) { // optimization: suppress attribute error from module getattro method *result = _Py_module_getattro_impl((PyModuleObject*)v, name, 1); if (*result != NULL) { From 40d6f23fc5bdd54e9f5521a8bf3f3a17674ff290 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 05:13:03 -0600 Subject: [PATCH 039/120] Make list_subscript() compatible with PyCFunction and binaryfunc --- Objects/listobject.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 4db586526a614e..574f091cb078ba 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2905,10 +2905,10 @@ list___sizeof___impl(PyListObject *self) } static PyObject *list_iter(PyObject *seq); -static PyObject *list_subscript(PyListObject*, PyObject*); +static PyObject *list_subscript(PyObject*, PyObject*); static PyMethodDef list_methods[] = { - {"__getitem__", (PyCFunction)list_subscript, METH_O|METH_COEXIST, + {"__getitem__", list_subscript, METH_O|METH_COEXIST, PyDoc_STR("__getitem__($self, index, /)\n--\n\nReturn self[index].")}, LIST___REVERSED___METHODDEF LIST___SIZEOF___METHODDEF @@ -2941,8 +2941,9 @@ static PySequenceMethods list_as_sequence = { }; static PyObject * -list_subscript(PyListObject* self, PyObject* item) +list_subscript(PyObject* obj, PyObject* item) { + PyListObject* self = (PyListObject*)obj; if (_PyIndex_Check(item)) { Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -3158,7 +3159,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) static PyMappingMethods list_as_mapping = { list_length, - (binaryfunc)list_subscript, + list_subscript, (objobjargproc)list_ass_subscript }; From 38b1fe01a40399137e37fc55c464d510e94690df Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:39:03 -0600 Subject: [PATCH 040/120] Make listreviter_traverse() compatible with traverseproc --- Objects/listobject.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 574f091cb078ba..dfce4ac1b215a8 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3364,7 +3364,7 @@ typedef struct { } listreviterobject; static void listreviter_dealloc(listreviterobject *); -static int listreviter_traverse(listreviterobject *, visitproc, void *); +static int listreviter_traverse(PyObject *, visitproc, void *); static PyObject *listreviter_next(listreviterobject *); static PyObject *listreviter_len(listreviterobject *, PyObject *); static PyObject *listreviter_reduce(listreviterobject *, PyObject *); @@ -3400,7 +3400,7 @@ PyTypeObject PyListRevIter_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ 0, /* tp_doc */ - (traverseproc)listreviter_traverse, /* tp_traverse */ + listreviter_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ @@ -3441,9 +3441,9 @@ listreviter_dealloc(listreviterobject *it) } static int -listreviter_traverse(listreviterobject *it, visitproc visit, void *arg) +listreviter_traverse(PyObject *it, visitproc visit, void *arg) { - Py_VISIT(it->it_seq); + Py_VISIT(((listreviterobject *)it)->it_seq); return 0; } From d1a9d4604677875c00041a9c1eb0c6e9d8f39a2f Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:41:11 -0600 Subject: [PATCH 041/120] Make listreviter_dealloc() compatible with destructor --- Objects/listobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index dfce4ac1b215a8..b5b40e263eb289 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3363,7 +3363,7 @@ typedef struct { PyListObject *it_seq; /* Set to NULL when iterator is exhausted */ } listreviterobject; -static void listreviter_dealloc(listreviterobject *); +static void listreviter_dealloc(PyObject *); static int listreviter_traverse(PyObject *, visitproc, void *); static PyObject *listreviter_next(listreviterobject *); static PyObject *listreviter_len(listreviterobject *, PyObject *); @@ -3383,7 +3383,7 @@ PyTypeObject PyListRevIter_Type = { sizeof(listreviterobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)listreviter_dealloc, /* tp_dealloc */ + listreviter_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ @@ -3433,8 +3433,9 @@ list___reversed___impl(PyListObject *self) } static void -listreviter_dealloc(listreviterobject *it) +listreviter_dealloc(PyObject *self) { + listreviterobject *it = (listreviterobject *)self; PyObject_GC_UnTrack(it); Py_XDECREF(it->it_seq); PyObject_GC_Del(it); From f9183219497f91a7762de4f031828ead8a0dde17 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:43:28 -0600 Subject: [PATCH 042/120] Make listreviter_next() compatible with iternextfunc --- Objects/listobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index b5b40e263eb289..a588b07b897717 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3365,7 +3365,7 @@ typedef struct { static void listreviter_dealloc(PyObject *); static int listreviter_traverse(PyObject *, visitproc, void *); -static PyObject *listreviter_next(listreviterobject *); +static PyObject *listreviter_next(PyObject *); static PyObject *listreviter_len(listreviterobject *, PyObject *); static PyObject *listreviter_reduce(listreviterobject *, PyObject *); static PyObject *listreviter_setstate(listreviterobject *, PyObject *); @@ -3405,7 +3405,7 @@ PyTypeObject PyListRevIter_Type = { 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ PyObject_SelfIter, /* tp_iter */ - (iternextfunc)listreviter_next, /* tp_iternext */ + listreviter_next, /* tp_iternext */ listreviter_methods, /* tp_methods */ 0, }; @@ -3449,8 +3449,9 @@ listreviter_traverse(PyObject *it, visitproc visit, void *arg) } static PyObject * -listreviter_next(listreviterobject *it) +listreviter_next(PyObject *self) { + listreviterobject *it = (listreviterobject *)self; PyObject *item; Py_ssize_t index; PyListObject *seq; From 11057ae7930a82c74fae2ae17afdfc1c4841346d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:46:54 -0600 Subject: [PATCH 043/120] Make listiter_traverse() compatible with traverseproc --- Objects/listobject.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index a588b07b897717..7bc477abb2da9a 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3211,7 +3211,7 @@ PyTypeObject PyList_Type = { /*********************** List Iterator **************************/ static void listiter_dealloc(PyObject *); -static int listiter_traverse(_PyListIterObject *, visitproc, void *); +static int listiter_traverse(PyObject *, visitproc, void *); static PyObject *listiter_next(PyObject *); static PyObject *listiter_len(_PyListIterObject *, PyObject *); static PyObject *listiter_reduce_general(void *_it, int forward); @@ -3252,7 +3252,7 @@ PyTypeObject PyListIter_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ 0, /* tp_doc */ - (traverseproc)listiter_traverse, /* tp_traverse */ + listiter_traverse, /* tp_traverse */ 0, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ @@ -3291,9 +3291,9 @@ listiter_dealloc(PyObject *obj) } static int -listiter_traverse(_PyListIterObject *it, visitproc visit, void *arg) +listiter_traverse(PyObject *it, visitproc visit, void *arg) { - Py_VISIT(it->it_seq); + Py_VISIT(((_PyListIterObject *)it)->it_seq); return 0; } From 72ef5bb78682eb30c2a2d530fa14e976144255cf Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:49:32 -0600 Subject: [PATCH 044/120] Make listreviter_len() compatible with PyCFunction --- Objects/listobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 7bc477abb2da9a..8c33e53be69193 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3366,12 +3366,12 @@ typedef struct { static void listreviter_dealloc(PyObject *); static int listreviter_traverse(PyObject *, visitproc, void *); static PyObject *listreviter_next(PyObject *); -static PyObject *listreviter_len(listreviterobject *, PyObject *); +static PyObject *listreviter_len(PyObject *, PyObject *); static PyObject *listreviter_reduce(listreviterobject *, PyObject *); static PyObject *listreviter_setstate(listreviterobject *, PyObject *); static PyMethodDef listreviter_methods[] = { - {"__length_hint__", (PyCFunction)listreviter_len, METH_NOARGS, length_hint_doc}, + {"__length_hint__", listreviter_len, METH_NOARGS, length_hint_doc}, {"__reduce__", (PyCFunction)listreviter_reduce, METH_NOARGS, reduce_doc}, {"__setstate__", (PyCFunction)listreviter_setstate, METH_O, setstate_doc}, {NULL, NULL} /* sentinel */ @@ -3476,8 +3476,9 @@ listreviter_next(PyObject *self) } static PyObject * -listreviter_len(listreviterobject *it, PyObject *Py_UNUSED(ignored)) +listreviter_len(PyObject *self, PyObject *Py_UNUSED(ignored)) { + listreviterobject *it = (listreviterobject *)self; Py_ssize_t len = it->it_index + 1; if (it->it_seq == NULL || PyList_GET_SIZE(it->it_seq) < len) len = 0; From 0ca5716f7d6ab9918c4d81ea4571d7eef8449bfe Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:51:38 -0600 Subject: [PATCH 045/120] Make listreviter_reduce() compatible with PyCFunction --- Objects/listobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 8c33e53be69193..981bb96d249d93 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3367,12 +3367,12 @@ static void listreviter_dealloc(PyObject *); static int listreviter_traverse(PyObject *, visitproc, void *); static PyObject *listreviter_next(PyObject *); static PyObject *listreviter_len(PyObject *, PyObject *); -static PyObject *listreviter_reduce(listreviterobject *, PyObject *); +static PyObject *listreviter_reduce(PyObject *, PyObject *); static PyObject *listreviter_setstate(listreviterobject *, PyObject *); static PyMethodDef listreviter_methods[] = { {"__length_hint__", listreviter_len, METH_NOARGS, length_hint_doc}, - {"__reduce__", (PyCFunction)listreviter_reduce, METH_NOARGS, reduce_doc}, + {"__reduce__", listreviter_reduce, METH_NOARGS, reduce_doc}, {"__setstate__", (PyCFunction)listreviter_setstate, METH_O, setstate_doc}, {NULL, NULL} /* sentinel */ }; @@ -3486,7 +3486,7 @@ listreviter_len(PyObject *self, PyObject *Py_UNUSED(ignored)) } static PyObject * -listreviter_reduce(listreviterobject *it, PyObject *Py_UNUSED(ignored)) +listreviter_reduce(PyObject *it, PyObject *Py_UNUSED(ignored)) { return listiter_reduce_general(it, 0); } From 9c5bb2956983e8f7fa10c2043ec50f0f41f0d5b0 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:55:25 -0600 Subject: [PATCH 046/120] Make listreviter_setstate() compatible with PyCFunction --- Objects/listobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 981bb96d249d93..11f11b3f6dfee3 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3368,12 +3368,12 @@ static int listreviter_traverse(PyObject *, visitproc, void *); static PyObject *listreviter_next(PyObject *); static PyObject *listreviter_len(PyObject *, PyObject *); static PyObject *listreviter_reduce(PyObject *, PyObject *); -static PyObject *listreviter_setstate(listreviterobject *, PyObject *); +static PyObject *listreviter_setstate(PyObject *, PyObject *); static PyMethodDef listreviter_methods[] = { {"__length_hint__", listreviter_len, METH_NOARGS, length_hint_doc}, {"__reduce__", listreviter_reduce, METH_NOARGS, reduce_doc}, - {"__setstate__", (PyCFunction)listreviter_setstate, METH_O, setstate_doc}, + {"__setstate__", listreviter_setstate, METH_O, setstate_doc}, {NULL, NULL} /* sentinel */ }; @@ -3492,8 +3492,9 @@ listreviter_reduce(PyObject *it, PyObject *Py_UNUSED(ignored)) } static PyObject * -listreviter_setstate(listreviterobject *it, PyObject *state) +listreviter_setstate(PyObject *self, PyObject *state) { + listreviterobject *it = (listreviterobject *)self; Py_ssize_t index = PyLong_AsSsize_t(state); if (index == -1 && PyErr_Occurred()) return NULL; From bd1645591d8a1cbf2f203c15914785624348c8de Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:57:46 -0600 Subject: [PATCH 047/120] Make list_contains() compatible with objobjproc --- Objects/listobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 11f11b3f6dfee3..808f6486c0be06 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -442,8 +442,9 @@ list_length(PyObject *a) } static int -list_contains(PyListObject *a, PyObject *el) +list_contains(PyObject *aa, PyObject *el) { + PyListObject *a = (PyListObject *)aa; PyObject *item; Py_ssize_t i; int cmp; @@ -2935,7 +2936,7 @@ static PySequenceMethods list_as_sequence = { 0, /* sq_slice */ list_ass_item, /* sq_ass_item */ 0, /* sq_ass_slice */ - (objobjproc)list_contains, /* sq_contains */ + list_contains, /* sq_contains */ (binaryfunc)list_inplace_concat, /* sq_inplace_concat */ (ssizeargfunc)list_inplace_repeat, /* sq_inplace_repeat */ }; From 09fbab9a0cbeb6b31803f469b0b9086785b0ace4 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:59:51 -0600 Subject: [PATCH 048/120] Make list_inplace_concat() compatible with binaryfunc --- Objects/listobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 808f6486c0be06..3fef693333b1f0 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -1052,8 +1052,9 @@ PyList_Clear(PyObject *self) static PyObject * -list_inplace_concat(PyListObject *self, PyObject *other) +list_inplace_concat(PyObject *obj, PyObject *other) { + PyListObject *self = (PyListObject *)obj; if (list_extend(self, other) < 0) { return NULL; } @@ -2937,7 +2938,7 @@ static PySequenceMethods list_as_sequence = { list_ass_item, /* sq_ass_item */ 0, /* sq_ass_slice */ list_contains, /* sq_contains */ - (binaryfunc)list_inplace_concat, /* sq_inplace_concat */ + list_inplace_concat, /* sq_inplace_concat */ (ssizeargfunc)list_inplace_repeat, /* sq_inplace_repeat */ }; From 92aa1f014f033d6fe4a8b434c4cae177ac877c01 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:04:36 -0600 Subject: [PATCH 049/120] Make list_ass_subscript() compatible with objobjargproc --- Objects/listobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 3fef693333b1f0..636c4af337d669 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2998,8 +2998,9 @@ list_subscript(PyObject* obj, PyObject* item) } static int -list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) +list_ass_subscript(PyObject* _self, PyObject* item, PyObject* value) { + PyListObject *self = (PyListObject *)_self; if (_PyIndex_Check(item)) { Py_ssize_t i = PyNumber_AsSsize_t(item, PyExc_IndexError); if (i == -1 && PyErr_Occurred()) @@ -3162,7 +3163,7 @@ list_ass_subscript(PyListObject* self, PyObject* item, PyObject* value) static PyMappingMethods list_as_mapping = { list_length, list_subscript, - (objobjargproc)list_ass_subscript + list_ass_subscript }; PyTypeObject PyList_Type = { From 352bf4189b865b601dde4e4b08b3312e144df046 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:07:32 -0600 Subject: [PATCH 050/120] Make listiter_len() compatible with PyCFunction --- Objects/listobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 636c4af337d669..4f6f4de5fe4617 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3216,7 +3216,7 @@ PyTypeObject PyList_Type = { static void listiter_dealloc(PyObject *); static int listiter_traverse(PyObject *, visitproc, void *); static PyObject *listiter_next(PyObject *); -static PyObject *listiter_len(_PyListIterObject *, PyObject *); +static PyObject *listiter_len(PyObject *, PyObject *); static PyObject *listiter_reduce_general(void *_it, int forward); static PyObject *listiter_reduce(_PyListIterObject *, PyObject *); static PyObject *listiter_setstate(_PyListIterObject *, PyObject *state); @@ -3226,7 +3226,7 @@ PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); PyDoc_STRVAR(setstate_doc, "Set state information for unpickling."); static PyMethodDef listiter_methods[] = { - {"__length_hint__", (PyCFunction)listiter_len, METH_NOARGS, length_hint_doc}, + {"__length_hint__", listiter_len, METH_NOARGS, length_hint_doc}, {"__reduce__", (PyCFunction)listiter_reduce, METH_NOARGS, reduce_doc}, {"__setstate__", (PyCFunction)listiter_setstate, METH_O, setstate_doc}, {NULL, NULL} /* sentinel */ @@ -3325,8 +3325,9 @@ listiter_next(PyObject *obj) } static PyObject * -listiter_len(_PyListIterObject *it, PyObject *Py_UNUSED(ignored)) +listiter_len(PyObject *self, PyObject *Py_UNUSED(ignored)) { + _PyListIterObject *it = (_PyListIterObject *)self; Py_ssize_t len; if (it->it_seq) { len = PyList_GET_SIZE(it->it_seq) - it->it_index; From 9b1b12ed3687ffbc427ec7a2a169b745c87bcd98 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:08:34 -0600 Subject: [PATCH 051/120] Make listiter_reduce() compatible with PyCFunction --- Objects/listobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 4f6f4de5fe4617..aae2ccbf770aae 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3218,7 +3218,7 @@ static int listiter_traverse(PyObject *, visitproc, void *); static PyObject *listiter_next(PyObject *); static PyObject *listiter_len(PyObject *, PyObject *); static PyObject *listiter_reduce_general(void *_it, int forward); -static PyObject *listiter_reduce(_PyListIterObject *, PyObject *); +static PyObject *listiter_reduce(PyObject *, PyObject *); static PyObject *listiter_setstate(_PyListIterObject *, PyObject *state); PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); @@ -3227,7 +3227,7 @@ PyDoc_STRVAR(setstate_doc, "Set state information for unpickling."); static PyMethodDef listiter_methods[] = { {"__length_hint__", listiter_len, METH_NOARGS, length_hint_doc}, - {"__reduce__", (PyCFunction)listiter_reduce, METH_NOARGS, reduce_doc}, + {"__reduce__", listiter_reduce, METH_NOARGS, reduce_doc}, {"__setstate__", (PyCFunction)listiter_setstate, METH_O, setstate_doc}, {NULL, NULL} /* sentinel */ }; @@ -3338,7 +3338,7 @@ listiter_len(PyObject *self, PyObject *Py_UNUSED(ignored)) } static PyObject * -listiter_reduce(_PyListIterObject *it, PyObject *Py_UNUSED(ignored)) +listiter_reduce(PyObject *it, PyObject *Py_UNUSED(ignored)) { return listiter_reduce_general(it, 1); } From f04084fd37f6520a6f9511d2d45232d755ce571d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:13:00 -0600 Subject: [PATCH 052/120] Make listiter_setstate() compatible with PyCFunction --- Objects/listobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index aae2ccbf770aae..7fc9d57ef32998 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -3219,7 +3219,7 @@ static PyObject *listiter_next(PyObject *); static PyObject *listiter_len(PyObject *, PyObject *); static PyObject *listiter_reduce_general(void *_it, int forward); static PyObject *listiter_reduce(PyObject *, PyObject *); -static PyObject *listiter_setstate(_PyListIterObject *, PyObject *state); +static PyObject *listiter_setstate(PyObject *, PyObject *state); PyDoc_STRVAR(length_hint_doc, "Private method returning an estimate of len(list(it))."); PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); @@ -3228,7 +3228,7 @@ PyDoc_STRVAR(setstate_doc, "Set state information for unpickling."); static PyMethodDef listiter_methods[] = { {"__length_hint__", listiter_len, METH_NOARGS, length_hint_doc}, {"__reduce__", listiter_reduce, METH_NOARGS, reduce_doc}, - {"__setstate__", (PyCFunction)listiter_setstate, METH_O, setstate_doc}, + {"__setstate__", listiter_setstate, METH_O, setstate_doc}, {NULL, NULL} /* sentinel */ }; @@ -3344,8 +3344,9 @@ listiter_reduce(PyObject *it, PyObject *Py_UNUSED(ignored)) } static PyObject * -listiter_setstate(_PyListIterObject *it, PyObject *state) +listiter_setstate(PyObject *self, PyObject *state) { + _PyListIterObject *it = (_PyListIterObject *)self; Py_ssize_t index = PyLong_AsSsize_t(state); if (index == -1 && PyErr_Occurred()) return NULL; From d0b13f53b951c296177e742563f225b18bc6e9ce Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:15:35 -0600 Subject: [PATCH 053/120] Fix warning in list_subscript() Objects/listobject.c:2956:26: warning: incompatible pointer types passing 'PyListObject *' to parameter of type 'PyObject *' (aka 'struct _object *') [-Wincompatible-pointer-types] 2956 | return list_item(self, i); | ^~~~ --- Objects/listobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index 7fc9d57ef32998..bcbfaa5a90c40b 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2953,7 +2953,7 @@ list_subscript(PyObject* obj, PyObject* item) return NULL; if (i < 0) i += PyList_GET_SIZE(self); - return list_item(self, i); + return list_item((PyObject *)self, i); } else if (PySlice_Check(item)) { Py_ssize_t start, stop, step, slicelength, i; From f8b435dfb5f75607500331986d435a288ff1ef45 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:24:35 -0600 Subject: [PATCH 054/120] Make list_inplace_repeat() compatible with ssizeargfunc --- Objects/listobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index bcbfaa5a90c40b..c66d03556e597e 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -752,8 +752,9 @@ PyList_SetSlice(PyObject *a, Py_ssize_t ilow, Py_ssize_t ihigh, PyObject *v) } static PyObject * -list_inplace_repeat(PyListObject *self, Py_ssize_t n) +list_inplace_repeat(PyObject *_self, Py_ssize_t n) { + PyListObject *self = (PyListObject *)_self; Py_ssize_t input_size = PyList_GET_SIZE(self); if (input_size == 0 || n == 1) { return Py_NewRef(self); @@ -2939,7 +2940,7 @@ static PySequenceMethods list_as_sequence = { 0, /* sq_ass_slice */ list_contains, /* sq_contains */ list_inplace_concat, /* sq_inplace_concat */ - (ssizeargfunc)list_inplace_repeat, /* sq_inplace_repeat */ + list_inplace_repeat, /* sq_inplace_repeat */ }; static PyObject * From 56535d51b55f98caf129d965c3b92e36607e47f7 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:35:29 -0600 Subject: [PATCH 055/120] Slightly less inconsistent parameter names --- Objects/listobject.c | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/Objects/listobject.c b/Objects/listobject.c index c66d03556e597e..dfb8cd2b106511 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -343,9 +343,9 @@ PyList_Append(PyObject *op, PyObject *newitem) /* Methods */ static void -list_dealloc(PyObject *obj) +list_dealloc(PyObject *self) { - PyListObject *op = (PyListObject *)obj; + PyListObject *op = (PyListObject *)self; Py_ssize_t i; PyObject_GC_UnTrack(op); Py_TRASHCAN_BEGIN(op, list_dealloc) @@ -379,9 +379,9 @@ list_dealloc(PyObject *obj) } static PyObject * -list_repr(PyObject *obj) +list_repr(PyObject *self) { - PyListObject *v = (PyListObject *)obj; + PyListObject *v = (PyListObject *)self; Py_ssize_t i; PyObject *s; _PyUnicodeWriter writer; @@ -622,10 +622,9 @@ list_clear(PyListObject *a) } static int -list_clear_slot(PyObject *obj) +list_clear_slot(PyObject *self) { - PyListObject *self = (PyListObject *)obj; - list_clear(self); + list_clear((PyListObject *)self); return 0; } @@ -784,9 +783,9 @@ list_inplace_repeat(PyObject *_self, Py_ssize_t n) } static int -list_ass_item(PyObject *obj, Py_ssize_t i, PyObject *v) +list_ass_item(PyObject *aa, Py_ssize_t i, PyObject *v) { - PyListObject *a = (PyListObject *)obj; + PyListObject *a = (PyListObject *)aa; if (!valid_index(i, Py_SIZE(a))) { PyErr_SetString(PyExc_IndexError, "list assignment index out of range"); @@ -1053,9 +1052,9 @@ PyList_Clear(PyObject *self) static PyObject * -list_inplace_concat(PyObject *obj, PyObject *other) +list_inplace_concat(PyObject *_self, PyObject *other) { - PyListObject *self = (PyListObject *)obj; + PyListObject *self = (PyListObject *)_self; if (list_extend(self, other) < 0) { return NULL; } @@ -2766,9 +2765,9 @@ list_remove(PyListObject *self, PyObject *value) } static int -list_traverse(PyObject *obj, visitproc visit, void *arg) +list_traverse(PyObject *self, visitproc visit, void *arg) { - PyListObject *o = (PyListObject *)obj; + PyListObject *o = (PyListObject *)self; Py_ssize_t i; for (i = Py_SIZE(o); --i >= 0; ) @@ -2944,9 +2943,9 @@ static PySequenceMethods list_as_sequence = { }; static PyObject * -list_subscript(PyObject* obj, PyObject* item) +list_subscript(PyObject* _self, PyObject* item) { - PyListObject* self = (PyListObject*)obj; + PyListObject* self = (PyListObject*)_self; if (_PyIndex_Check(item)) { Py_ssize_t i; i = PyNumber_AsSsize_t(item, PyExc_IndexError); @@ -3286,9 +3285,9 @@ list_iter(PyObject *seq) } static void -listiter_dealloc(PyObject *obj) +listiter_dealloc(PyObject *self) { - _PyListIterObject *it = (_PyListIterObject *)obj; + _PyListIterObject *it = (_PyListIterObject *)self; _PyObject_GC_UNTRACK(it); Py_XDECREF(it->it_seq); PyObject_GC_Del(it); @@ -3302,9 +3301,9 @@ listiter_traverse(PyObject *it, visitproc visit, void *arg) } static PyObject * -listiter_next(PyObject *obj) +listiter_next(PyObject *self) { - _PyListIterObject *it = (_PyListIterObject *)obj; + _PyListIterObject *it = (_PyListIterObject *)self; PyListObject *seq; PyObject *item; From 5f45a6cafd2b32fbe14a341303eda1354d9dc41d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 20:00:50 -0600 Subject: [PATCH 056/120] Do not cast long_long_meth() to getter --- Objects/longobject.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c index 843f1f6f24d18d..6579cdae34df1d 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -6201,9 +6201,15 @@ static PyMethodDef long_methods[] = { {NULL, NULL} /* sentinel */ }; +static PyObject * +long_long_meth_getter(PyObject *self, void *arg) +{ + return long_long_meth(self, arg); +} + static PyGetSetDef long_getset[] = { {"real", - (getter)long_long_meth, (setter)NULL, + long_long_meth_getter, (setter)NULL, "the real part of a complex number", NULL}, {"imag", @@ -6211,7 +6217,7 @@ static PyGetSetDef long_getset[] = { "the imaginary part of a complex number", NULL}, {"numerator", - (getter)long_long_meth, (setter)NULL, + long_long_meth_getter, (setter)NULL, "the numerator of a rational number in lowest terms", NULL}, {"denominator", From 2ee81acefdb4ee8f1f9e1998a78a40e87ad12374 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 17:00:40 -0600 Subject: [PATCH 057/120] Make method_repr() compatible with reprfunc --- Objects/descrobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index d0fb714dbeac78..707051428f4a6b 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -48,7 +48,7 @@ descr_repr(PyDescrObject *descr, const char *format) } static PyObject * -method_repr(PyMethodDescrObject *descr) +method_repr(PyObject *descr) { return descr_repr((PyDescrObject *)descr, ""); @@ -712,7 +712,7 @@ PyTypeObject PyMethodDescr_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)method_repr, /* tp_repr */ + method_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ @@ -752,7 +752,7 @@ PyTypeObject PyClassMethodDescr_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)method_repr, /* tp_repr */ + method_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ From d6eeb6f93a36497b28a2b6369d6894f5b2e57d05 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 17:02:30 -0600 Subject: [PATCH 058/120] Make classmethoddescr_call() compatible with ternaryfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 707051428f4a6b..e4122cfee107c6 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -486,9 +486,10 @@ method_vectorcall_O( we implement this simply by calling __get__ and then calling the result. */ static PyObject * -classmethoddescr_call(PyMethodDescrObject *descr, PyObject *args, +classmethoddescr_call(PyObject *_descr, PyObject *args, PyObject *kwds) { + PyMethodDescrObject *descr = (PyMethodDescrObject *)_descr; Py_ssize_t argc = PyTuple_GET_SIZE(args); if (argc < 1) { PyErr_Format(PyExc_TypeError, @@ -757,7 +758,7 @@ PyTypeObject PyClassMethodDescr_Type = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ - (ternaryfunc)classmethoddescr_call, /* tp_call */ + classmethoddescr_call, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ From 767b5dc3b951095356c0a9b2931c2579ae0c2b7f Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:31:49 -0600 Subject: [PATCH 059/120] Make getset_repr() compatible with reprfunc --- Objects/descrobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index e4122cfee107c6..c9ff456f6e9504 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -62,7 +62,7 @@ member_repr(PyMemberDescrObject *descr) } static PyObject * -getset_repr(PyGetSetDescrObject *descr) +getset_repr(PyObject *descr) { return descr_repr((PyDescrObject *)descr, ""); @@ -827,7 +827,7 @@ PyTypeObject PyGetSetDescr_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)getset_repr, /* tp_repr */ + getset_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ From e522d74f1444ed8542945f65680df3433c1bdf6d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:39:20 -0600 Subject: [PATCH 060/120] Make member_repr() compatible with reprfunc --- Objects/descrobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index c9ff456f6e9504..874ae0a92c8bf8 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -55,7 +55,7 @@ method_repr(PyObject *descr) } static PyObject * -member_repr(PyMemberDescrObject *descr) +member_repr(PyObject *descr) { return descr_repr((PyDescrObject *)descr, ""); @@ -790,7 +790,7 @@ PyTypeObject PyMemberDescr_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)member_repr, /* tp_repr */ + member_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ From 3d7c7f2b8d8768732131798bafd9726ffb910464 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:41:29 -0600 Subject: [PATCH 061/120] Make wrapperdescr_repr() compatible with reprfunc --- Objects/descrobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 874ae0a92c8bf8..8d08dea3ca23b9 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -69,7 +69,7 @@ getset_repr(PyObject *descr) } static PyObject * -wrapperdescr_repr(PyWrapperDescrObject *descr) +wrapperdescr_repr(PyObject *descr) { return descr_repr((PyDescrObject *)descr, ""); @@ -864,7 +864,7 @@ PyTypeObject PyWrapperDescr_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)wrapperdescr_repr, /* tp_repr */ + wrapperdescr_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ From 3497a20a52335e81f020cbd9fdbf4ab53adb6836 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:42:31 -0600 Subject: [PATCH 062/120] Make wrapperdescr_call() compatible with ternaryfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 8d08dea3ca23b9..5a9e960ac8aaf7 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -531,8 +531,9 @@ wrapperdescr_raw_call(PyWrapperDescrObject *descr, PyObject *self, } static PyObject * -wrapperdescr_call(PyWrapperDescrObject *descr, PyObject *args, PyObject *kwds) +wrapperdescr_call(PyObject *_descr, PyObject *args, PyObject *kwds) { + PyWrapperDescrObject *descr = (PyWrapperDescrObject *)_descr; Py_ssize_t argc; PyObject *self, *result; @@ -869,7 +870,7 @@ PyTypeObject PyWrapperDescr_Type = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ 0, /* tp_hash */ - (ternaryfunc)wrapperdescr_call, /* tp_call */ + wrapperdescr_call, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ From cc4fe8474bbfc05e85c1bec5b3664e0ec0d1abf5 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:43:56 -0600 Subject: [PATCH 063/120] Make wrapper_repr() compatible with reprfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 5a9e960ac8aaf7..d71a528c0c6b57 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1330,8 +1330,9 @@ wrapper_hash(wrapperobject *wp) } static PyObject * -wrapper_repr(wrapperobject *wp) +wrapper_repr(PyObject *self) { + wrapperobject *wp = (wrapperobject *)self; return PyUnicode_FromFormat("", wp->descr->d_base->name, Py_TYPE(wp->self)->tp_name, @@ -1425,7 +1426,7 @@ PyTypeObject _PyMethodWrapper_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)wrapper_repr, /* tp_repr */ + wrapper_repr, /* tp_repr */ 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ From e593ad60681acf332e6645c029c8372a6cdc58fb Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:45:46 -0600 Subject: [PATCH 064/120] Make wrapper_reduce() compatible with PyCFunction --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index d71a528c0c6b57..e2cc4531c0bd26 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1340,14 +1340,15 @@ wrapper_repr(PyObject *self) } static PyObject * -wrapper_reduce(wrapperobject *wp, PyObject *Py_UNUSED(ignored)) +wrapper_reduce(PyObject *self, PyObject *Py_UNUSED(ignored)) { + wrapperobject *wp = (wrapperobject *)self; return Py_BuildValue("N(OO)", _PyEval_GetBuiltin(&_Py_ID(getattr)), wp->self, PyDescr_NAME(wp->descr)); } static PyMethodDef wrapper_methods[] = { - {"__reduce__", (PyCFunction)wrapper_reduce, METH_NOARGS, NULL}, + {"__reduce__", wrapper_reduce, METH_NOARGS, NULL}, {NULL, NULL} }; From e59192bebd1756458bcf9daec81db98a7d94547d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:49:14 -0600 Subject: [PATCH 065/120] Make wrapper_hash() compatible with hashfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index e2cc4531c0bd26..a6a98bdf914e66 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1318,8 +1318,9 @@ wrapper_richcompare(PyObject *a, PyObject *b, int op) } static Py_hash_t -wrapper_hash(wrapperobject *wp) +wrapper_hash(PyObject *self) { + wrapperobject *wp = (wrapperobject *)self; Py_hash_t x, y; x = _Py_HashPointer(wp->self); y = _Py_HashPointer(wp->descr); @@ -1431,7 +1432,7 @@ PyTypeObject _PyMethodWrapper_Type = { 0, /* tp_as_number */ 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ - (hashfunc)wrapper_hash, /* tp_hash */ + wrapper_hash, /* tp_hash */ (ternaryfunc)wrapper_call, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ From 4abe2ed851265dc55fc4ae3b87e4d9451e0629e7 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:52:09 -0600 Subject: [PATCH 066/120] Make wrapper_dealloc() compatible with destructor --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index a6a98bdf914e66..d8c374f1dace42 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1281,8 +1281,9 @@ typedef struct { #define Wrapper_Check(v) Py_IS_TYPE(v, &_PyMethodWrapper_Type) static void -wrapper_dealloc(wrapperobject *wp) +wrapper_dealloc(PyObject *self) { + wrapperobject *wp = (wrapperobject *)self; PyObject_GC_UnTrack(wp); Py_TRASHCAN_BEGIN(wp, wrapper_dealloc) Py_XDECREF(wp->descr); @@ -1423,7 +1424,7 @@ PyTypeObject _PyMethodWrapper_Type = { sizeof(wrapperobject), /* tp_basicsize */ 0, /* tp_itemsize */ /* methods */ - (destructor)wrapper_dealloc, /* tp_dealloc */ + wrapper_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ From 5c2306b3c634703b7ad9985dfd01d28af15cdf4f Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:53:53 -0600 Subject: [PATCH 067/120] Make wrapper_objclass() compatible with getter --- Objects/descrobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index d8c374f1dace42..749de54c1449c0 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1360,9 +1360,9 @@ static PyMemberDef wrapper_members[] = { }; static PyObject * -wrapper_objclass(wrapperobject *wp, void *Py_UNUSED(ignored)) +wrapper_objclass(PyObject *wp, void *Py_UNUSED(ignored)) { - PyObject *c = (PyObject *)PyDescr_TYPE(wp->descr); + PyObject *c = (PyObject *)PyDescr_TYPE(((wrapperobject *)wp)->descr); return Py_NewRef(c); } @@ -1395,7 +1395,7 @@ wrapper_qualname(wrapperobject *wp, void *Py_UNUSED(ignored)) } static PyGetSetDef wrapper_getsets[] = { - {"__objclass__", (getter)wrapper_objclass}, + {"__objclass__", wrapper_objclass}, {"__name__", (getter)wrapper_name}, {"__qualname__", (getter)wrapper_qualname}, {"__doc__", (getter)wrapper_doc}, From 58a420de6161c84d889d8ff07080fd3545940d82 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:54:55 -0600 Subject: [PATCH 068/120] Make wrapper_name() compatible with getter --- Objects/descrobject.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 749de54c1449c0..6f7e36ac171a79 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1368,9 +1368,9 @@ wrapper_objclass(PyObject *wp, void *Py_UNUSED(ignored)) } static PyObject * -wrapper_name(wrapperobject *wp, void *Py_UNUSED(ignored)) +wrapper_name(PyObject *wp, void *Py_UNUSED(ignored)) { - const char *s = wp->descr->d_base->name; + const char *s = ((wrapperobject *)wp)->descr->d_base->name; return PyUnicode_FromString(s); } @@ -1396,7 +1396,7 @@ wrapper_qualname(wrapperobject *wp, void *Py_UNUSED(ignored)) static PyGetSetDef wrapper_getsets[] = { {"__objclass__", wrapper_objclass}, - {"__name__", (getter)wrapper_name}, + {"__name__", wrapper_name}, {"__qualname__", (getter)wrapper_qualname}, {"__doc__", (getter)wrapper_doc}, {"__text_signature__", (getter)wrapper_text_signature}, From ce18b5a8e269abe98bbdff3d8c28d29cccde3f95 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:05:37 -0600 Subject: [PATCH 069/120] Make wrapper_qualname() compatible with getter --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 6f7e36ac171a79..ec6bc1c33aef4b 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1389,15 +1389,16 @@ wrapper_text_signature(wrapperobject *wp, void *Py_UNUSED(ignored)) } static PyObject * -wrapper_qualname(wrapperobject *wp, void *Py_UNUSED(ignored)) +wrapper_qualname(PyObject *self, void *Py_UNUSED(ignored)) { + wrapperobject *wp = (wrapperobject *)self; return descr_get_qualname((PyDescrObject *)wp->descr, NULL); } static PyGetSetDef wrapper_getsets[] = { {"__objclass__", wrapper_objclass}, {"__name__", wrapper_name}, - {"__qualname__", (getter)wrapper_qualname}, + {"__qualname__", wrapper_qualname}, {"__doc__", (getter)wrapper_doc}, {"__text_signature__", (getter)wrapper_text_signature}, {0} From ed40e79ed477de4e78f938361c3244985c0e1c9d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:06:55 -0600 Subject: [PATCH 070/120] Make wrapper_text_signature() compatible with getter --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index ec6bc1c33aef4b..ce2c6d0275ae58 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1382,8 +1382,9 @@ wrapper_doc(wrapperobject *wp, void *Py_UNUSED(ignored)) } static PyObject * -wrapper_text_signature(wrapperobject *wp, void *Py_UNUSED(ignored)) +wrapper_text_signature(PyObject *self, void *Py_UNUSED(ignored)) { + wrapperobject *wp = (wrapperobject *)self; return _PyType_GetTextSignatureFromInternalDoc(wp->descr->d_base->name, wp->descr->d_base->doc, 0); } @@ -1400,7 +1401,7 @@ static PyGetSetDef wrapper_getsets[] = { {"__name__", wrapper_name}, {"__qualname__", wrapper_qualname}, {"__doc__", (getter)wrapper_doc}, - {"__text_signature__", (getter)wrapper_text_signature}, + {"__text_signature__", wrapper_text_signature}, {0} }; From fd8b63f44075ddc13bc12704eecec4f27239d681 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:07:36 -0600 Subject: [PATCH 071/120] Make wrapper_doc() compatible with getter --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index ce2c6d0275ae58..d2028199a14971 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1376,8 +1376,9 @@ wrapper_name(PyObject *wp, void *Py_UNUSED(ignored)) } static PyObject * -wrapper_doc(wrapperobject *wp, void *Py_UNUSED(ignored)) +wrapper_doc(PyObject *self, void *Py_UNUSED(ignored)) { + wrapperobject *wp = (wrapperobject *)self; return _PyType_GetDocFromInternalDoc(wp->descr->d_base->name, wp->descr->d_base->doc); } @@ -1400,7 +1401,7 @@ static PyGetSetDef wrapper_getsets[] = { {"__objclass__", wrapper_objclass}, {"__name__", wrapper_name}, {"__qualname__", wrapper_qualname}, - {"__doc__", (getter)wrapper_doc}, + {"__doc__", wrapper_doc}, {"__text_signature__", wrapper_text_signature}, {0} }; From 71f39dcb17fb95166068d2fcf28ce61563bac963 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:44:24 -0600 Subject: [PATCH 072/120] Fix long_abs() warnings Objects/longobject.c:5339:34: warning: incompatible pointer types passing 'PyLongObject *' (aka 'struct _longobject *') to parameter of type 'PyObject *' (aka 'struct _object *') [-Wincompatible-pointer-types] 5339 | a = (PyLongObject *)long_abs(a); | ^ Objects/longobject.c:5342:34: warning: incompatible pointer types passing 'PyLongObject *' (aka 'struct _longobject *') to parameter of type 'PyObject *' (aka 'struct _object *') [-Wincompatible-pointer-types] 5342 | b = (PyLongObject *)long_abs(b); | ^ Objects/longobject.c:4882:20: note: passing argument to parameter 'obj' here 4882 | long_abs(PyObject *obj) | ^ --- Objects/longobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/longobject.c b/Objects/longobject.c index 6579cdae34df1d..ad637f5485b107 100644 --- a/Objects/longobject.c +++ b/Objects/longobject.c @@ -5336,10 +5336,10 @@ _PyLong_GCD(PyObject *aarg, PyObject *barg) } /* Initial reduction: make sure that 0 <= b <= a. */ - a = (PyLongObject *)long_abs(a); + a = (PyLongObject *)long_abs((PyObject *)a); if (a == NULL) return NULL; - b = (PyLongObject *)long_abs(b); + b = (PyLongObject *)long_abs((PyObject *)b); if (b == NULL) { Py_DECREF(a); return NULL; From 9b26eac89adf7e76fa28ed397156aa092a4cce0b Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:54:44 -0600 Subject: [PATCH 073/120] mappingproxy_dealloc(): less inconsistent parameter name --- Objects/descrobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index d2028199a14971..e4f9e89260b9e2 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1165,9 +1165,9 @@ static PyMethodDef mappingproxy_methods[] = { }; static void -mappingproxy_dealloc(PyObject *obj) +mappingproxy_dealloc(PyObject *self) { - mappingproxyobject *pp = (mappingproxyobject *)obj; + mappingproxyobject *pp = (mappingproxyobject *)self; _PyObject_GC_UNTRACK(pp); Py_DECREF(pp->mapping); PyObject_GC_Del(pp); From b7a1fa7a9a55996a3da358018f4bed162e55635b Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:54:57 -0600 Subject: [PATCH 074/120] descr_dealloc(): less inconsistent parameter name --- Objects/descrobject.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index e4f9e89260b9e2..b99fec6579bb20 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -19,9 +19,9 @@ class property "propertyobject *" "&PyProperty_Type" /*[clinic end generated code: output=da39a3ee5e6b4b0d input=556352653fd4c02e]*/ static void -descr_dealloc(PyObject *obj) +descr_dealloc(PyObject *self) { - PyDescrObject *descr = (PyDescrObject *)obj; + PyDescrObject *descr = (PyDescrObject *)self; _PyObject_GC_UNTRACK(descr); Py_XDECREF(descr->d_type); Py_XDECREF(descr->d_name); From 6708d568a17edbb52a18a5ea595e63f404a520d8 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:57:43 -0600 Subject: [PATCH 075/120] Make mappingproxy_getiter() compatible with getiterfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index b99fec6579bb20..30b76ffcdfa69f 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1174,8 +1174,9 @@ mappingproxy_dealloc(PyObject *self) } static PyObject * -mappingproxy_getiter(mappingproxyobject *pp) +mappingproxy_getiter(PyObject *self) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_GetIter(pp->mapping); } @@ -1949,7 +1950,7 @@ PyTypeObject PyDictProxy_Type = { 0, /* tp_clear */ (richcmpfunc)mappingproxy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ - (getiterfunc)mappingproxy_getiter, /* tp_iter */ + mappingproxy_getiter, /* tp_iter */ 0, /* tp_iternext */ mappingproxy_methods, /* tp_methods */ 0, /* tp_members */ From 31df0201548d6b83bb20f9186def185cc91f81dc Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:58:14 -0600 Subject: [PATCH 076/120] Make mappingproxy_hash() compatible with hashfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 30b76ffcdfa69f..69988a53f3b337 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1181,8 +1181,9 @@ mappingproxy_getiter(PyObject *self) } static Py_hash_t -mappingproxy_hash(mappingproxyobject *pp) +mappingproxy_hash(PyObject *self) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_Hash(pp->mapping); } @@ -1937,7 +1938,7 @@ PyTypeObject PyDictProxy_Type = { &mappingproxy_as_number, /* tp_as_number */ &mappingproxy_as_sequence, /* tp_as_sequence */ &mappingproxy_as_mapping, /* tp_as_mapping */ - (hashfunc)mappingproxy_hash, /* tp_hash */ + mappingproxy_hash, /* tp_hash */ 0, /* tp_call */ (reprfunc)mappingproxy_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ From 29000776be00747f2c5f56e6bfcd028644800484 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:58:57 -0600 Subject: [PATCH 077/120] Make mappingproxy_str() compatible with reprfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 69988a53f3b337..aa0e96004a1970 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1188,8 +1188,9 @@ mappingproxy_hash(PyObject *self) } static PyObject * -mappingproxy_str(mappingproxyobject *pp) +mappingproxy_str(PyObject *self) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_Str(pp->mapping); } @@ -1940,7 +1941,7 @@ PyTypeObject PyDictProxy_Type = { &mappingproxy_as_mapping, /* tp_as_mapping */ mappingproxy_hash, /* tp_hash */ 0, /* tp_call */ - (reprfunc)mappingproxy_str, /* tp_str */ + mappingproxy_str, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ 0, /* tp_as_buffer */ From 71fb253cda3b174b2c373f14a85072de52f0aa7b Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:59:50 -0600 Subject: [PATCH 078/120] Make mappingproxy_repr() compatible with reprfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index aa0e96004a1970..7b024352c0084f 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1195,8 +1195,9 @@ mappingproxy_str(PyObject *self) } static PyObject * -mappingproxy_repr(mappingproxyobject *pp) +mappingproxy_repr(PyObject *self) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyUnicode_FromFormat("mappingproxy(%R)", pp->mapping); } @@ -1935,7 +1936,7 @@ PyTypeObject PyDictProxy_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)mappingproxy_repr, /* tp_repr */ + mappingproxy_repr, /* tp_repr */ &mappingproxy_as_number, /* tp_as_number */ &mappingproxy_as_sequence, /* tp_as_sequence */ &mappingproxy_as_mapping, /* tp_as_mapping */ From 59f20acd5d181cdd6b2d036045913f76ecaf17d8 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:01:12 -0600 Subject: [PATCH 079/120] Make mappingproxy_richcompare() compatible with richcmpfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 7b024352c0084f..020c548d1b8ba8 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1210,8 +1210,9 @@ mappingproxy_traverse(PyObject *self, visitproc visit, void *arg) } static PyObject * -mappingproxy_richcompare(mappingproxyobject *v, PyObject *w, int op) +mappingproxy_richcompare(PyObject *self, PyObject *w, int op) { + mappingproxyobject *v = (mappingproxyobject *)self; return PyObject_RichCompare(v->mapping, w, op); } @@ -1951,7 +1952,7 @@ PyTypeObject PyDictProxy_Type = { 0, /* tp_doc */ mappingproxy_traverse, /* tp_traverse */ 0, /* tp_clear */ - (richcmpfunc)mappingproxy_richcompare, /* tp_richcompare */ + mappingproxy_richcompare, /* tp_richcompare */ 0, /* tp_weaklistoffset */ mappingproxy_getiter, /* tp_iter */ 0, /* tp_iternext */ From e928c836a0c7f062a969c9886d4dbbced35d0c20 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:02:13 -0600 Subject: [PATCH 080/120] Remove unnecessary cast of property_clear() --- Objects/descrobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 020c548d1b8ba8..e309388a9d0952 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1994,7 +1994,7 @@ PyTypeObject PyProperty_Type = { Py_TPFLAGS_BASETYPE, /* tp_flags */ property_init__doc__, /* tp_doc */ property_traverse, /* tp_traverse */ - (inquiry)property_clear, /* tp_clear */ + property_clear, /* tp_clear */ 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ 0, /* tp_iter */ From a59fea37b8632d712f6a2ae9be0ea06f31f11b8d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:15:10 -0600 Subject: [PATCH 081/120] Make mappingproxy_contains() compatible with objobjproc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index e309388a9d0952..64cd90104b963b 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1073,8 +1073,9 @@ static PyNumberMethods mappingproxy_as_number = { }; static int -mappingproxy_contains(mappingproxyobject *pp, PyObject *key) +mappingproxy_contains(PyObject *self, PyObject *key) { + mappingproxyobject *pp = (mappingproxyobject *)self; if (PyDict_CheckExact(pp->mapping)) return PyDict_Contains(pp->mapping, key); else @@ -1089,7 +1090,7 @@ static PySequenceMethods mappingproxy_as_sequence = { 0, /* sq_slice */ 0, /* sq_ass_item */ 0, /* sq_ass_slice */ - (objobjproc)mappingproxy_contains, /* sq_contains */ + mappingproxy_contains, /* sq_contains */ 0, /* sq_inplace_concat */ 0, /* sq_inplace_repeat */ }; From 65e484228b72651139a3318db4d0451499ea59a6 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:17:45 -0600 Subject: [PATCH 082/120] Make wrapper_call() compatible with ternaryfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 64cd90104b963b..fe5407b225f390 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1413,8 +1413,9 @@ static PyGetSetDef wrapper_getsets[] = { }; static PyObject * -wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds) +wrapper_call(PyObject *self, PyObject *args, PyObject *kwds) { + wrapperobject *wp = (wrapperobject *)self; return wrapperdescr_raw_call(wp->descr, wp->self, args, kwds); } @@ -1443,7 +1444,7 @@ PyTypeObject _PyMethodWrapper_Type = { 0, /* tp_as_sequence */ 0, /* tp_as_mapping */ wrapper_hash, /* tp_hash */ - (ternaryfunc)wrapper_call, /* tp_call */ + wrapper_call, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ 0, /* tp_setattro */ From 460edb2f655dc1f6e33064984edad9421c5a7449 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:19:27 -0600 Subject: [PATCH 083/120] Make mappingproxy_reversed() compatible with PyCFunction --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index fe5407b225f390..44e481356fff0f 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1138,8 +1138,9 @@ mappingproxy_copy(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) } static PyObject * -mappingproxy_reversed(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) +mappingproxy_reversed(PyObject *self, PyObject *Py_UNUSED(ignored)) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(__reversed__)); } @@ -1160,7 +1161,7 @@ static PyMethodDef mappingproxy_methods[] = { PyDoc_STR("D.copy() -> a shallow copy of D")}, {"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")}, - {"__reversed__", (PyCFunction)mappingproxy_reversed, METH_NOARGS, + {"__reversed__", mappingproxy_reversed, METH_NOARGS, PyDoc_STR("D.__reversed__() -> reverse iterator")}, {0} }; From 837cc6f1c40f0549fa6f4d82a4a4e607c88233a4 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:20:01 -0600 Subject: [PATCH 084/120] Make mappingproxy_copy() compatible with PyCFunction --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 44e481356fff0f..ffeb9ba4885f04 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1132,8 +1132,9 @@ mappingproxy_items(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) } static PyObject * -mappingproxy_copy(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) +mappingproxy_copy(PyObject *self, PyObject *Py_UNUSED(ignored)) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(copy)); } @@ -1157,7 +1158,7 @@ static PyMethodDef mappingproxy_methods[] = { PyDoc_STR("D.values() -> an object providing a view on D's values")}, {"items", (PyCFunction)mappingproxy_items, METH_NOARGS, PyDoc_STR("D.items() -> a set-like object providing a view on D's items")}, - {"copy", (PyCFunction)mappingproxy_copy, METH_NOARGS, + {"copy", mappingproxy_copy, METH_NOARGS, PyDoc_STR("D.copy() -> a shallow copy of D")}, {"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, PyDoc_STR("See PEP 585")}, From c75a5db277a9ec928ca74ceeb032c3391556b1f0 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:20:41 -0600 Subject: [PATCH 085/120] Make mappingproxy_items() compatible with PyCFunction --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index ffeb9ba4885f04..9a4cfda430b68b 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1126,8 +1126,9 @@ mappingproxy_values(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) } static PyObject * -mappingproxy_items(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) +mappingproxy_items(PyObject *self, PyObject *Py_UNUSED(ignored)) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(items)); } @@ -1156,7 +1157,7 @@ static PyMethodDef mappingproxy_methods[] = { PyDoc_STR("D.keys() -> a set-like object providing a view on D's keys")}, {"values", (PyCFunction)mappingproxy_values, METH_NOARGS, PyDoc_STR("D.values() -> an object providing a view on D's values")}, - {"items", (PyCFunction)mappingproxy_items, METH_NOARGS, + {"items", mappingproxy_items, METH_NOARGS, PyDoc_STR("D.items() -> a set-like object providing a view on D's items")}, {"copy", mappingproxy_copy, METH_NOARGS, PyDoc_STR("D.copy() -> a shallow copy of D")}, From be4ebdbc29b293841e775652e2f4e1dc98cc114e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:21:12 -0600 Subject: [PATCH 086/120] Make mappingproxy_values() compatible with PyCFunction --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 9a4cfda430b68b..aaa07e1f0a80d8 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1120,8 +1120,9 @@ mappingproxy_keys(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) } static PyObject * -mappingproxy_values(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) +mappingproxy_values(PyObject *self, PyObject *Py_UNUSED(ignored)) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(values)); } @@ -1155,7 +1156,7 @@ static PyMethodDef mappingproxy_methods[] = { " d defaults to None.")}, {"keys", (PyCFunction)mappingproxy_keys, METH_NOARGS, PyDoc_STR("D.keys() -> a set-like object providing a view on D's keys")}, - {"values", (PyCFunction)mappingproxy_values, METH_NOARGS, + {"values", mappingproxy_values, METH_NOARGS, PyDoc_STR("D.values() -> an object providing a view on D's values")}, {"items", mappingproxy_items, METH_NOARGS, PyDoc_STR("D.items() -> a set-like object providing a view on D's items")}, From 313779bd532afe942139ba09386897b1cd2e884f Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:21:42 -0600 Subject: [PATCH 087/120] Make mappingproxy_keys() compatible with PyCFunction --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index aaa07e1f0a80d8..385b6272fa40dc 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1114,8 +1114,9 @@ mappingproxy_get(mappingproxyobject *pp, PyObject *const *args, Py_ssize_t nargs } static PyObject * -mappingproxy_keys(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) +mappingproxy_keys(PyObject *self, PyObject *Py_UNUSED(ignored)) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_CallMethodNoArgs(pp->mapping, &_Py_ID(keys)); } @@ -1154,7 +1155,7 @@ static PyMethodDef mappingproxy_methods[] = { {"get", _PyCFunction_CAST(mappingproxy_get), METH_FASTCALL, PyDoc_STR("D.get(k[,d]) -> D[k] if k in D, else d." " d defaults to None.")}, - {"keys", (PyCFunction)mappingproxy_keys, METH_NOARGS, + {"keys", mappingproxy_keys, METH_NOARGS, PyDoc_STR("D.keys() -> a set-like object providing a view on D's keys")}, {"values", mappingproxy_values, METH_NOARGS, PyDoc_STR("D.values() -> an object providing a view on D's values")}, From 0f19d6b81f0a1f3c28c8bef4ae8cb6a1205e4e73 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:23:54 -0600 Subject: [PATCH 088/120] Make mappingproxy_getitem() compatible with binaryfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 385b6272fa40dc..7dc1aee1f203cc 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1037,14 +1037,15 @@ mappingproxy_len(mappingproxyobject *pp) } static PyObject * -mappingproxy_getitem(mappingproxyobject *pp, PyObject *key) +mappingproxy_getitem(PyObject *self, PyObject *key) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_GetItem(pp->mapping, key); } static PyMappingMethods mappingproxy_as_mapping = { (lenfunc)mappingproxy_len, /* mp_length */ - (binaryfunc)mappingproxy_getitem, /* mp_subscript */ + mappingproxy_getitem, /* mp_subscript */ 0, /* mp_ass_subscript */ }; From e98780edef4a533101321b97c0d8ba36fb70bafd Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:24:41 -0600 Subject: [PATCH 089/120] Make mappingproxy_len() compatible with lenfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 7dc1aee1f203cc..a28d8e99ead683 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1031,8 +1031,9 @@ typedef struct { } mappingproxyobject; static Py_ssize_t -mappingproxy_len(mappingproxyobject *pp) +mappingproxy_len(PyObject *self) { + mappingproxyobject *pp = (mappingproxyobject *)self; return PyObject_Size(pp->mapping); } @@ -1044,7 +1045,7 @@ mappingproxy_getitem(PyObject *self, PyObject *key) } static PyMappingMethods mappingproxy_as_mapping = { - (lenfunc)mappingproxy_len, /* mp_length */ + mappingproxy_len, /* mp_length */ mappingproxy_getitem, /* mp_subscript */ 0, /* mp_ass_subscript */ }; From 76f7cb3c1bb1d3a11595f553583d85d7f1d51588 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:25:25 -0600 Subject: [PATCH 090/120] Make method_get_doc() compatible with getter --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index a28d8e99ead683..1ede4070c10573 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -572,8 +572,9 @@ wrapperdescr_call(PyObject *_descr, PyObject *args, PyObject *kwds) static PyObject * -method_get_doc(PyMethodDescrObject *descr, void *closure) +method_get_doc(PyObject *_descr, void *closure) { + PyMethodDescrObject *descr = (PyMethodDescrObject *)_descr; return _PyType_GetDocFromInternalDoc(descr->d_method->ml_name, descr->d_method->ml_doc); } @@ -640,7 +641,7 @@ static PyMemberDef descr_members[] = { }; static PyGetSetDef method_getset[] = { - {"__doc__", (getter)method_get_doc}, + {"__doc__", method_get_doc}, {"__qualname__", (getter)descr_get_qualname}, {"__text_signature__", (getter)method_get_text_signature}, {0} From 205e70bf8915dd2e680e4207c02b9e3ff03da547 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:31:01 -0600 Subject: [PATCH 091/120] Make descr_get_qualname() compatible with getter --- Objects/descrobject.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 1ede4070c10573..3ce2ecc73afb5e 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -615,8 +615,9 @@ calculate_qualname(PyDescrObject *descr) } static PyObject * -descr_get_qualname(PyDescrObject *descr, void *Py_UNUSED(ignored)) +descr_get_qualname(PyObject *self, void *Py_UNUSED(ignored)) { + PyDescrObject *descr = (PyDescrObject *)self; if (descr->d_qualname == NULL) descr->d_qualname = calculate_qualname(descr); return Py_XNewRef(descr->d_qualname); @@ -642,7 +643,7 @@ static PyMemberDef descr_members[] = { static PyGetSetDef method_getset[] = { {"__doc__", method_get_doc}, - {"__qualname__", (getter)descr_get_qualname}, + {"__qualname__", descr_get_qualname}, {"__text_signature__", (getter)method_get_text_signature}, {0} }; @@ -658,7 +659,7 @@ member_get_doc(PyMemberDescrObject *descr, void *closure) static PyGetSetDef member_getset[] = { {"__doc__", (getter)member_get_doc}, - {"__qualname__", (getter)descr_get_qualname}, + {"__qualname__", descr_get_qualname}, {0} }; @@ -673,7 +674,7 @@ getset_get_doc(PyGetSetDescrObject *descr, void *closure) static PyGetSetDef getset_getset[] = { {"__doc__", (getter)getset_get_doc}, - {"__qualname__", (getter)descr_get_qualname}, + {"__qualname__", descr_get_qualname}, {0} }; @@ -692,7 +693,7 @@ wrapperdescr_get_text_signature(PyWrapperDescrObject *descr, void *closure) static PyGetSetDef wrapperdescr_getset[] = { {"__doc__", (getter)wrapperdescr_get_doc}, - {"__qualname__", (getter)descr_get_qualname}, + {"__qualname__", descr_get_qualname}, {"__text_signature__", (getter)wrapperdescr_get_text_signature}, {0} }; From ce48153de073a7baf1e85a40d08ecf4f4b024024 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:32:03 -0600 Subject: [PATCH 092/120] Make method_get_text_signature() compatible with getter --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 3ce2ecc73afb5e..62adf69df57745 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -579,8 +579,9 @@ method_get_doc(PyObject *_descr, void *closure) } static PyObject * -method_get_text_signature(PyMethodDescrObject *descr, void *closure) +method_get_text_signature(PyObject *_descr, void *closure) { + PyMethodDescrObject *descr = (PyMethodDescrObject *)_descr; return _PyType_GetTextSignatureFromInternalDoc(descr->d_method->ml_name, descr->d_method->ml_doc, descr->d_method->ml_flags); @@ -644,7 +645,7 @@ static PyMemberDef descr_members[] = { static PyGetSetDef method_getset[] = { {"__doc__", method_get_doc}, {"__qualname__", descr_get_qualname}, - {"__text_signature__", (getter)method_get_text_signature}, + {"__text_signature__", method_get_text_signature}, {0} }; From dc10519b91e48aa40c6eae9340cf6992ca4e96f4 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:33:35 -0600 Subject: [PATCH 093/120] Make member_get_doc() compatible with getter --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 62adf69df57745..5a1a8b120f607f 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -650,8 +650,9 @@ static PyGetSetDef method_getset[] = { }; static PyObject * -member_get_doc(PyMemberDescrObject *descr, void *closure) +member_get_doc(PyObject *_descr, void *closure) { + PyMemberDescrObject *descr = (PyMemberDescrObject *)_descr; if (descr->d_member->doc == NULL) { Py_RETURN_NONE; } @@ -659,7 +660,7 @@ member_get_doc(PyMemberDescrObject *descr, void *closure) } static PyGetSetDef member_getset[] = { - {"__doc__", (getter)member_get_doc}, + {"__doc__", member_get_doc}, {"__qualname__", descr_get_qualname}, {0} }; From 8f694367bdb888534904d1786682809001483022 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:35:17 -0600 Subject: [PATCH 094/120] Make getset_get_doc() compatible with getter --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 5a1a8b120f607f..33a259a5c2b53f 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -666,8 +666,9 @@ static PyGetSetDef member_getset[] = { }; static PyObject * -getset_get_doc(PyGetSetDescrObject *descr, void *closure) +getset_get_doc(PyObject *self, void *closure) { + PyGetSetDescrObject *descr = (PyGetSetDescrObject *)self; if (descr->d_getset->doc == NULL) { Py_RETURN_NONE; } @@ -675,7 +676,7 @@ getset_get_doc(PyGetSetDescrObject *descr, void *closure) } static PyGetSetDef getset_getset[] = { - {"__doc__", (getter)getset_get_doc}, + {"__doc__", getset_get_doc}, {"__qualname__", descr_get_qualname}, {0} }; From c0e7158c6330e7266e69d7b3c2d37daf8bd2dd06 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:37:11 -0600 Subject: [PATCH 095/120] Make wrapperdescr_get_doc() compatible with getter --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 33a259a5c2b53f..71a7991b7099a6 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -682,8 +682,9 @@ static PyGetSetDef getset_getset[] = { }; static PyObject * -wrapperdescr_get_doc(PyWrapperDescrObject *descr, void *closure) +wrapperdescr_get_doc(PyObject *self, void *closure) { + PyWrapperDescrObject *descr = (PyWrapperDescrObject *)self; return _PyType_GetDocFromInternalDoc(descr->d_base->name, descr->d_base->doc); } @@ -695,7 +696,7 @@ wrapperdescr_get_text_signature(PyWrapperDescrObject *descr, void *closure) } static PyGetSetDef wrapperdescr_getset[] = { - {"__doc__", (getter)wrapperdescr_get_doc}, + {"__doc__", wrapperdescr_get_doc}, {"__qualname__", descr_get_qualname}, {"__text_signature__", (getter)wrapperdescr_get_text_signature}, {0} From 1a2a2e6203abb53d2d6959a3ab5879b86894f2cf Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:37:46 -0600 Subject: [PATCH 096/120] Make wrapperdescr_get_text_signature() compatible with getter --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 71a7991b7099a6..2379887867a5f3 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -689,8 +689,9 @@ wrapperdescr_get_doc(PyObject *self, void *closure) } static PyObject * -wrapperdescr_get_text_signature(PyWrapperDescrObject *descr, void *closure) +wrapperdescr_get_text_signature(PyObject *self, void *closure) { + PyWrapperDescrObject *descr = (PyWrapperDescrObject *)self; return _PyType_GetTextSignatureFromInternalDoc(descr->d_base->name, descr->d_base->doc, 0); } @@ -698,7 +699,7 @@ wrapperdescr_get_text_signature(PyWrapperDescrObject *descr, void *closure) static PyGetSetDef wrapperdescr_getset[] = { {"__doc__", wrapperdescr_get_doc}, {"__qualname__", descr_get_qualname}, - {"__text_signature__", (getter)wrapperdescr_get_text_signature}, + {"__text_signature__", wrapperdescr_get_text_signature}, {0} }; From 716a227cb44ec836723f378b0277b3a196b04ed3 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:39:15 -0600 Subject: [PATCH 097/120] Make wrapperdescr_get() compatible with descrgetfunc --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 2379887867a5f3..f25b0661d28ff0 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -200,8 +200,9 @@ getset_get(PyObject *self, PyObject *obj, PyObject *type) } static PyObject * -wrapperdescr_get(PyWrapperDescrObject *descr, PyObject *obj, PyObject *type) +wrapperdescr_get(PyObject *self, PyObject *obj, PyObject *type) { + PyWrapperDescrObject *descr = (PyWrapperDescrObject *)self; if (obj == NULL) { return Py_NewRef(descr); } @@ -896,7 +897,7 @@ PyTypeObject PyWrapperDescr_Type = { wrapperdescr_getset, /* tp_getset */ 0, /* tp_base */ 0, /* tp_dict */ - (descrgetfunc)wrapperdescr_get, /* tp_descr_get */ + wrapperdescr_get, /* tp_descr_get */ 0, /* tp_descr_set */ }; From 78f8508ebe4400c8842bb76bad382aa266fccacd Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:41:10 -0600 Subject: [PATCH 098/120] Make descr_reduce() compatible with PyCFunction --- Objects/descrobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index f25b0661d28ff0..0debe356f803f0 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -626,14 +626,15 @@ descr_get_qualname(PyObject *self, void *Py_UNUSED(ignored)) } static PyObject * -descr_reduce(PyDescrObject *descr, PyObject *Py_UNUSED(ignored)) +descr_reduce(PyObject *self, PyObject *Py_UNUSED(ignored)) { + PyDescrObject *descr = (PyDescrObject *)self; return Py_BuildValue("N(OO)", _PyEval_GetBuiltin(&_Py_ID(getattr)), PyDescr_TYPE(descr), PyDescr_NAME(descr)); } static PyMethodDef descr_methods[] = { - {"__reduce__", (PyCFunction)descr_reduce, METH_NOARGS, NULL}, + {"__reduce__", descr_reduce, METH_NOARGS, NULL}, {NULL, NULL} }; From 1a1764eb8f2afbb2feeb9627a0465d7b08d5ea50 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:15:18 -0600 Subject: [PATCH 099/120] Make memory_clear() compatible with inquiry --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index bcdd2ff0ceafe6..09fa11af661237 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1156,8 +1156,9 @@ memory_traverse(PyMemoryViewObject *self, visitproc visit, void *arg) } static int -memory_clear(PyMemoryViewObject *self) +memory_clear(PyObject *_self) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; (void)_memory_release(self); Py_CLEAR(self->mbuf); return 0; @@ -3391,7 +3392,7 @@ PyTypeObject PyMemoryView_Type = { Py_TPFLAGS_SEQUENCE, /* tp_flags */ memoryview__doc__, /* tp_doc */ (traverseproc)memory_traverse, /* tp_traverse */ - (inquiry)memory_clear, /* tp_clear */ + memory_clear, /* tp_clear */ memory_richcompare, /* tp_richcompare */ offsetof(PyMemoryViewObject, weakreflist),/* tp_weaklistoffset */ memory_iter, /* tp_iter */ From 5bbfb2506df142910af6f7b00a502235aea63190 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:16:38 -0600 Subject: [PATCH 100/120] Make memory_traverse() compatible with traverseproc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 09fa11af661237..fac021e7c4e0e3 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1149,8 +1149,9 @@ memory_dealloc(PyMemoryViewObject *self) } static int -memory_traverse(PyMemoryViewObject *self, visitproc visit, void *arg) +memory_traverse(PyObject *_self, visitproc visit, void *arg) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_VISIT(self->mbuf); return 0; } @@ -3391,7 +3392,7 @@ PyTypeObject PyMemoryView_Type = { Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_SEQUENCE, /* tp_flags */ memoryview__doc__, /* tp_doc */ - (traverseproc)memory_traverse, /* tp_traverse */ + memory_traverse, /* tp_traverse */ memory_clear, /* tp_clear */ memory_richcompare, /* tp_richcompare */ offsetof(PyMemoryViewObject, weakreflist),/* tp_weaklistoffset */ From 72d4e6821e870e15e1a6f7aafa92ec4a1b86f3dd Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:17:37 -0600 Subject: [PATCH 101/120] Make memory_dealloc() compatible with destructor --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index fac021e7c4e0e3..018e2e9970d8a3 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1137,8 +1137,9 @@ memoryview_release_impl(PyMemoryViewObject *self) } static void -memory_dealloc(PyMemoryViewObject *self) +memory_dealloc(PyObject *_self) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; assert(self->exports == 0); _PyObject_GC_UNTRACK(self); (void)_memory_release(self); @@ -3374,7 +3375,7 @@ PyTypeObject PyMemoryView_Type = { "memoryview", /* tp_name */ offsetof(PyMemoryViewObject, ob_array), /* tp_basicsize */ sizeof(Py_ssize_t), /* tp_itemsize */ - (destructor)memory_dealloc, /* tp_dealloc */ + memory_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ From 67d4515e16aab4e5e6e72c4aaa1d9e0e5b1a0762 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:19:01 -0600 Subject: [PATCH 102/120] Make memory_repr() compatible with reprfunc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 018e2e9970d8a3..9d98888aa947ea 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -2347,8 +2347,9 @@ memoryview_hex_impl(PyMemoryViewObject *self, PyObject *sep, } static PyObject * -memory_repr(PyMemoryViewObject *self) +memory_repr(PyObject *_self) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; if (self->flags & _Py_MEMORYVIEW_RELEASED) return PyUnicode_FromFormat("", self); else @@ -3380,7 +3381,7 @@ PyTypeObject PyMemoryView_Type = { 0, /* tp_getattr */ 0, /* tp_setattr */ 0, /* tp_as_async */ - (reprfunc)memory_repr, /* tp_repr */ + memory_repr, /* tp_repr */ 0, /* tp_as_number */ &memory_as_sequence, /* tp_as_sequence */ &memory_as_mapping, /* tp_as_mapping */ From 77ccab59bbe96e38b937a9f6eee967736dc7b299 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:20:24 -0600 Subject: [PATCH 103/120] Make memory_hash() compatible with hashfunc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 9d98888aa947ea..b358949208f213 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -3038,8 +3038,9 @@ memory_richcompare(PyObject *v, PyObject *w, int op) /**************************************************************************/ static Py_hash_t -memory_hash(PyMemoryViewObject *self) +memory_hash(PyObject *_self) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; if (self->hash == -1) { Py_buffer *view = &self->view; char *mem = view->buf; @@ -3385,7 +3386,7 @@ PyTypeObject PyMemoryView_Type = { 0, /* tp_as_number */ &memory_as_sequence, /* tp_as_sequence */ &memory_as_mapping, /* tp_as_mapping */ - (hashfunc)memory_hash, /* tp_hash */ + memory_hash, /* tp_hash */ 0, /* tp_call */ 0, /* tp_str */ PyObject_GenericGetAttr, /* tp_getattro */ From c60ce495263dda86a02acf43d2051d2074fc5e22 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:23:47 -0600 Subject: [PATCH 104/120] Make memoryiter_next() compatible with iternextfunc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index b358949208f213..f89640b933b522 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -3296,8 +3296,9 @@ memoryiter_traverse(memoryiterobject *it, visitproc visit, void *arg) } static PyObject * -memoryiter_next(memoryiterobject *it) +memoryiter_next(PyObject *self) { + memoryiterobject *it = (memoryiterobject *)self; PyMemoryViewObject *seq; seq = it->it_seq; if (seq == NULL) { @@ -3369,7 +3370,7 @@ PyTypeObject _PyMemoryIter_Type = { .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, .tp_traverse = (traverseproc)memoryiter_traverse, .tp_iter = PyObject_SelfIter, - .tp_iternext = (iternextfunc)memoryiter_next, + .tp_iternext = memoryiter_next, }; PyTypeObject PyMemoryView_Type = { From 4eab0a17c4a8c9585c3d9f9c6edbefd60bf6e73e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:24:35 -0600 Subject: [PATCH 105/120] Make memoryiter_traverse() compatible with traverseproc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index f89640b933b522..e6ecbf725c76da 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -3289,8 +3289,9 @@ memoryiter_dealloc(memoryiterobject *it) } static int -memoryiter_traverse(memoryiterobject *it, visitproc visit, void *arg) +memoryiter_traverse(PyObject *self, visitproc visit, void *arg) { + memoryiterobject *it = (memoryiterobject *)self; Py_VISIT(it->it_seq); return 0; } @@ -3368,7 +3369,7 @@ PyTypeObject _PyMemoryIter_Type = { .tp_dealloc = (destructor)memoryiter_dealloc, .tp_getattro = PyObject_GenericGetAttr, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, - .tp_traverse = (traverseproc)memoryiter_traverse, + .tp_traverse = memoryiter_traverse, .tp_iter = PyObject_SelfIter, .tp_iternext = memoryiter_next, }; From 9dea03cdfd03d935a1f72cd3a05f3098ca71b886 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:25:14 -0600 Subject: [PATCH 106/120] Make memoryiter_dealloc() compatible with destructor --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index e6ecbf725c76da..a03f2c1fc0def9 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -3281,8 +3281,9 @@ typedef struct { } memoryiterobject; static void -memoryiter_dealloc(memoryiterobject *it) +memoryiter_dealloc(PyObject *self) { + memoryiterobject *it = (memoryiterobject *)self; _PyObject_GC_UNTRACK(it); Py_XDECREF(it->it_seq); PyObject_GC_Del(it); @@ -3366,7 +3367,7 @@ PyTypeObject _PyMemoryIter_Type = { .tp_name = "memory_iterator", .tp_basicsize = sizeof(memoryiterobject), // methods - .tp_dealloc = (destructor)memoryiter_dealloc, + .tp_dealloc = memoryiter_dealloc, .tp_getattro = PyObject_GenericGetAttr, .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, .tp_traverse = memoryiter_traverse, From fd5cfbaa9d0d1ce24aa3dc76dfcafbeed8e030fc Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:31:28 -0600 Subject: [PATCH 107/120] Make several functions compatible with getter --- Objects/memoryobject.c | 45 +++++++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 18 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index a03f2c1fc0def9..2f59b2a56dcca7 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -3117,8 +3117,9 @@ _IntTupleFromSsizet(int len, Py_ssize_t *vals) } static PyObject * -memory_obj_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) +memory_obj_get(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *view = &self->view; CHECK_RELEASED(self); @@ -3129,57 +3130,65 @@ memory_obj_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) } static PyObject * -memory_nbytes_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) +memory_nbytes_get(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return PyLong_FromSsize_t(self->view.len); } static PyObject * -memory_format_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) +memory_format_get(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return PyUnicode_FromString(self->view.format); } static PyObject * -memory_itemsize_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) +memory_itemsize_get(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return PyLong_FromSsize_t(self->view.itemsize); } static PyObject * -memory_shape_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) +memory_shape_get(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return _IntTupleFromSsizet(self->view.ndim, self->view.shape); } static PyObject * -memory_strides_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) +memory_strides_get(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return _IntTupleFromSsizet(self->view.ndim, self->view.strides); } static PyObject * -memory_suboffsets_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) +memory_suboffsets_get(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return _IntTupleFromSsizet(self->view.ndim, self->view.suboffsets); } static PyObject * -memory_readonly_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) +memory_readonly_get(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return PyBool_FromLong(self->view.readonly); } static PyObject * -memory_ndim_get(PyMemoryViewObject *self, void *Py_UNUSED(ignored)) +memory_ndim_get(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return PyLong_FromLong(self->view.ndim); } @@ -3237,15 +3246,15 @@ PyDoc_STRVAR(memory_contiguous_doc, static PyGetSetDef memory_getsetlist[] = { - {"obj", (getter)memory_obj_get, NULL, memory_obj_doc}, - {"nbytes", (getter)memory_nbytes_get, NULL, memory_nbytes_doc}, - {"readonly", (getter)memory_readonly_get, NULL, memory_readonly_doc}, - {"itemsize", (getter)memory_itemsize_get, NULL, memory_itemsize_doc}, - {"format", (getter)memory_format_get, NULL, memory_format_doc}, - {"ndim", (getter)memory_ndim_get, NULL, memory_ndim_doc}, - {"shape", (getter)memory_shape_get, NULL, memory_shape_doc}, - {"strides", (getter)memory_strides_get, NULL, memory_strides_doc}, - {"suboffsets", (getter)memory_suboffsets_get, NULL, memory_suboffsets_doc}, + {"obj", memory_obj_get, NULL, memory_obj_doc}, + {"nbytes", memory_nbytes_get, NULL, memory_nbytes_doc}, + {"readonly", memory_readonly_get, NULL, memory_readonly_doc}, + {"itemsize", memory_itemsize_get, NULL, memory_itemsize_doc}, + {"format", memory_format_get, NULL, memory_format_doc}, + {"ndim", memory_ndim_get, NULL, memory_ndim_doc}, + {"shape", memory_shape_get, NULL, memory_shape_doc}, + {"strides", memory_strides_get, NULL, memory_strides_doc}, + {"suboffsets", memory_suboffsets_get, NULL, memory_suboffsets_doc}, {"c_contiguous", (getter)memory_c_contiguous, NULL, memory_c_contiguous_doc}, {"f_contiguous", (getter)memory_f_contiguous, NULL, memory_f_contiguous_doc}, {"contiguous", (getter)memory_contiguous, NULL, memory_contiguous_doc}, From a2b3c2553c1e557d51cba4c8803ca6ef096cd528 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 22:51:58 -0600 Subject: [PATCH 108/120] Make a few functions compatible with getter --- Objects/memoryobject.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 2f59b2a56dcca7..6adc0a25921eca 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -3194,22 +3194,25 @@ memory_ndim_get(PyObject *_self, void *Py_UNUSED(ignored)) } static PyObject * -memory_c_contiguous(PyMemoryViewObject *self, PyObject *dummy) +memory_c_contiguous(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return PyBool_FromLong(MV_C_CONTIGUOUS(self->flags)); } static PyObject * -memory_f_contiguous(PyMemoryViewObject *self, PyObject *dummy) +memory_f_contiguous(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return PyBool_FromLong(MV_F_CONTIGUOUS(self->flags)); } static PyObject * -memory_contiguous(PyMemoryViewObject *self, PyObject *dummy) +memory_contiguous(PyObject *_self, void *Py_UNUSED(ignored)) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED(self); return PyBool_FromLong(MV_ANY_CONTIGUOUS(self->flags)); } @@ -3255,9 +3258,9 @@ static PyGetSetDef memory_getsetlist[] = { {"shape", memory_shape_get, NULL, memory_shape_doc}, {"strides", memory_strides_get, NULL, memory_strides_doc}, {"suboffsets", memory_suboffsets_get, NULL, memory_suboffsets_doc}, - {"c_contiguous", (getter)memory_c_contiguous, NULL, memory_c_contiguous_doc}, - {"f_contiguous", (getter)memory_f_contiguous, NULL, memory_f_contiguous_doc}, - {"contiguous", (getter)memory_contiguous, NULL, memory_contiguous_doc}, + {"c_contiguous", memory_c_contiguous, NULL, memory_c_contiguous_doc}, + {"f_contiguous", memory_f_contiguous, NULL, memory_f_contiguous_doc}, + {"contiguous", memory_contiguous, NULL, memory_contiguous_doc}, {NULL, NULL, NULL, NULL}, }; From c092220bfd4b9b419619e4213bd918f71d5920a7 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 23:04:32 -0600 Subject: [PATCH 109/120] Make memory_item() compatible with ssizeargfunc --- Objects/memoryobject.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 6adc0a25921eca..702bd7a44d31c8 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -2425,8 +2425,9 @@ ptr_from_tuple(const Py_buffer *view, PyObject *tup) with the type specified by view->format. Otherwise, the item is a sub-view. The function is used in memory_subscript() and memory_as_sequence. */ static PyObject * -memory_item(PyMemoryViewObject *self, Py_ssize_t index) +memory_item(PyObject *_self, Py_ssize_t index) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *view = &(self->view); const char *fmt; @@ -2579,7 +2580,7 @@ memory_subscript(PyMemoryViewObject *self, PyObject *key) index = PyNumber_AsSsize_t(key, PyExc_IndexError); if (index == -1 && PyErr_Occurred()) return NULL; - return memory_item(self, index); + return memory_item((PyObject *)self, index); } else if (PySlice_Check(key)) { CHECK_RESTRICTED(self); @@ -2736,7 +2737,7 @@ static PySequenceMethods memory_as_sequence = { (lenfunc)memory_length, /* sq_length */ 0, /* sq_concat */ 0, /* sq_repeat */ - (ssizeargfunc)memory_item, /* sq_item */ + memory_item, /* sq_item */ }; From 4436a3149d5b1aa6c22fe2211d8f40e552c9e0ad Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 23:06:51 -0600 Subject: [PATCH 110/120] Make memory_subscript() compatible with binaryfunc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 702bd7a44d31c8..6c1f1615852145 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -2551,8 +2551,9 @@ is_multiindex(PyObject *key) 0-d memoryview objects can be referenced using mv[...] or mv[()] but not with anything else. */ static PyObject * -memory_subscript(PyMemoryViewObject *self, PyObject *key) +memory_subscript(PyObject *_self, PyObject *key) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *view; view = &(self->view); @@ -2728,7 +2729,7 @@ memory_length(PyMemoryViewObject *self) /* As mapping */ static PyMappingMethods memory_as_mapping = { (lenfunc)memory_length, /* mp_length */ - (binaryfunc)memory_subscript, /* mp_subscript */ + memory_subscript, /* mp_subscript */ (objobjargproc)memory_ass_sub, /* mp_ass_subscript */ }; From dc1ba48ef3f582213ee06acbb8d271c410b9cc1d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 23:10:38 -0600 Subject: [PATCH 111/120] Make memory_length() compatible with lenfunc --- Objects/memoryobject.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 6c1f1615852145..b8fed33260a5ca 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -2716,8 +2716,9 @@ memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value) } static Py_ssize_t -memory_length(PyMemoryViewObject *self) +memory_length(PyObject *_self) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; CHECK_RELEASED_INT(self); if (self->view.ndim == 0) { PyErr_SetString(PyExc_TypeError, "0-dim memory has no length"); @@ -2728,14 +2729,14 @@ memory_length(PyMemoryViewObject *self) /* As mapping */ static PyMappingMethods memory_as_mapping = { - (lenfunc)memory_length, /* mp_length */ + memory_length, /* mp_length */ memory_subscript, /* mp_subscript */ (objobjargproc)memory_ass_sub, /* mp_ass_subscript */ }; /* As sequence */ static PySequenceMethods memory_as_sequence = { - (lenfunc)memory_length, /* sq_length */ + memory_length, /* sq_length */ 0, /* sq_concat */ 0, /* sq_repeat */ memory_item, /* sq_item */ @@ -3369,7 +3370,7 @@ memory_iter(PyObject *seq) return NULL; } it->it_fmt = fmt; - it->it_length = memory_length(obj); + it->it_length = memory_length((PyObject *)obj); it->it_index = 0; it->it_seq = (PyMemoryViewObject*)Py_NewRef(obj); _PyObject_GC_TRACK(it); From 57782d806b4e67237bf6ae16b0ebfc4f3971400f Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 23:13:44 -0600 Subject: [PATCH 112/120] Make memory_ass_sub() compatible with objobjargproc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index b8fed33260a5ca..8f5df0e11d48ca 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -2614,8 +2614,9 @@ memory_subscript(PyObject *_self, PyObject *key) } static int -memory_ass_sub(PyMemoryViewObject *self, PyObject *key, PyObject *value) +memory_ass_sub(PyObject *_self, PyObject *key, PyObject *value) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *view = &(self->view); Py_buffer src; const char *fmt; @@ -2731,7 +2732,7 @@ memory_length(PyObject *_self) static PyMappingMethods memory_as_mapping = { memory_length, /* mp_length */ memory_subscript, /* mp_subscript */ - (objobjargproc)memory_ass_sub, /* mp_ass_subscript */ + memory_ass_sub, /* mp_ass_subscript */ }; /* As sequence */ From 14ec8df172f224900c9cc93df912b6315d19219d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 23:15:58 -0600 Subject: [PATCH 113/120] Make memory_releasebuf() compatible with releasebufferproc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 8f5df0e11d48ca..ef189d115c02fc 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1592,8 +1592,9 @@ memory_getbuf(PyMemoryViewObject *self, Py_buffer *view, int flags) } static void -memory_releasebuf(PyMemoryViewObject *self, Py_buffer *view) +memory_releasebuf(PyObject *_self, Py_buffer *view) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; self->exports--; return; /* PyBuffer_Release() decrements view->obj after this function returns. */ @@ -1602,7 +1603,7 @@ memory_releasebuf(PyMemoryViewObject *self, Py_buffer *view) /* Buffer methods */ static PyBufferProcs memory_as_buffer = { (getbufferproc)memory_getbuf, /* bf_getbuffer */ - (releasebufferproc)memory_releasebuf, /* bf_releasebuffer */ + memory_releasebuf, /* bf_releasebuffer */ }; From c2a9a4801bc8aadebb9a416f1a2b1426743031a0 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 23:17:12 -0600 Subject: [PATCH 114/120] Make memory_getbuf() compatible with getbufferproc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index ef189d115c02fc..1529463df7f685 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -1513,8 +1513,9 @@ memoryview_toreadonly_impl(PyMemoryViewObject *self) /**************************************************************************/ static int -memory_getbuf(PyMemoryViewObject *self, Py_buffer *view, int flags) +memory_getbuf(PyObject *_self, Py_buffer *view, int flags) { + PyMemoryViewObject *self = (PyMemoryViewObject *)_self; Py_buffer *base = &self->view; int baseflags = self->flags; @@ -1602,7 +1603,7 @@ memory_releasebuf(PyObject *_self, Py_buffer *view) /* Buffer methods */ static PyBufferProcs memory_as_buffer = { - (getbufferproc)memory_getbuf, /* bf_getbuffer */ + memory_getbuf, /* bf_getbuffer */ memory_releasebuf, /* bf_releasebuffer */ }; From 4b0faf84bffd3b733aa3a60297824d70501aa511 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 23:19:43 -0600 Subject: [PATCH 115/120] Make mbuf_clear() compatible with inquiry --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 1529463df7f685..ecdec7467d34f6 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -136,8 +136,9 @@ mbuf_traverse(_PyManagedBufferObject *self, visitproc visit, void *arg) } static int -mbuf_clear(_PyManagedBufferObject *self) +mbuf_clear(PyObject *_self) { + _PyManagedBufferObject *self = (_PyManagedBufferObject *)_self; assert(self->exports >= 0); mbuf_release(self); return 0; @@ -166,7 +167,7 @@ PyTypeObject _PyManagedBuffer_Type = { Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ 0, /* tp_doc */ (traverseproc)mbuf_traverse, /* tp_traverse */ - (inquiry)mbuf_clear /* tp_clear */ + mbuf_clear /* tp_clear */ }; From 706f1762237b3e5ad73e6c757131c2dcbf202594 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 23:21:07 -0600 Subject: [PATCH 116/120] Make mbuf_traverse() compatible with traverseproc --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index ecdec7467d34f6..94e2ab5943281a 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -129,8 +129,9 @@ mbuf_dealloc(_PyManagedBufferObject *self) } static int -mbuf_traverse(_PyManagedBufferObject *self, visitproc visit, void *arg) +mbuf_traverse(PyObject *_self, visitproc visit, void *arg) { + _PyManagedBufferObject *self = (_PyManagedBufferObject *)_self; Py_VISIT(self->master.obj); return 0; } @@ -166,7 +167,7 @@ PyTypeObject _PyManagedBuffer_Type = { 0, /* tp_as_buffer */ Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ 0, /* tp_doc */ - (traverseproc)mbuf_traverse, /* tp_traverse */ + mbuf_traverse, /* tp_traverse */ mbuf_clear /* tp_clear */ }; From 2d1bce907bc021c3bbcb028be26974fadf2e7d7a Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 23:23:00 -0600 Subject: [PATCH 117/120] Make mbuf_dealloc() compatible with destructor --- Objects/memoryobject.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 94e2ab5943281a..6d32e1c91d577a 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -119,8 +119,9 @@ mbuf_release(_PyManagedBufferObject *self) } static void -mbuf_dealloc(_PyManagedBufferObject *self) +mbuf_dealloc(PyObject *_self) { + _PyManagedBufferObject *self = (_PyManagedBufferObject *)_self; assert(self->exports == 0); mbuf_release(self); if (self->flags&_Py_MANAGED_BUFFER_FREE_FORMAT) @@ -150,7 +151,7 @@ PyTypeObject _PyManagedBuffer_Type = { "managedbuffer", sizeof(_PyManagedBufferObject), 0, - (destructor)mbuf_dealloc, /* tp_dealloc */ + mbuf_dealloc, /* tp_dealloc */ 0, /* tp_vectorcall_offset */ 0, /* tp_getattr */ 0, /* tp_setattr */ From f80bddc5a0c09e5f4fda62997ab58bed1f3e0e28 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Fri, 8 Dec 2023 01:39:20 -0600 Subject: [PATCH 118/120] Fix comment indentation --- Objects/memoryobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/memoryobject.c b/Objects/memoryobject.c index 6d32e1c91d577a..6a38952fdc1f3b 100644 --- a/Objects/memoryobject.c +++ b/Objects/memoryobject.c @@ -3419,7 +3419,7 @@ PyTypeObject PyMemoryView_Type = { Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_SEQUENCE, /* tp_flags */ memoryview__doc__, /* tp_doc */ - memory_traverse, /* tp_traverse */ + memory_traverse, /* tp_traverse */ memory_clear, /* tp_clear */ memory_richcompare, /* tp_richcompare */ offsetof(PyMemoryViewObject, weakreflist),/* tp_weaklistoffset */ From 1084d9bad40b8c1a437488684ba2a493f8bf361e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Fri, 8 Dec 2023 02:23:35 -0600 Subject: [PATCH 119/120] Need to update type in cast --- Objects/descrobject.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 0debe356f803f0..2bf1954670b9b5 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1416,7 +1416,7 @@ static PyObject * wrapper_qualname(PyObject *self, void *Py_UNUSED(ignored)) { wrapperobject *wp = (wrapperobject *)self; - return descr_get_qualname((PyDescrObject *)wp->descr, NULL); + return descr_get_qualname((PyObject *)wp->descr, NULL); } static PyGetSetDef wrapper_getsets[] = { From 29a6ba682f9a49a3fad569fe1843412d5c9dd13f Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Fri, 8 Dec 2023 20:47:24 -0600 Subject: [PATCH 120/120] Make mappingproxy_get() compatible with _PyCFunctionFast --- Objects/descrobject.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 2bf1954670b9b5..8d771adf307dc4 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1107,8 +1107,9 @@ static PySequenceMethods mappingproxy_as_sequence = { }; static PyObject * -mappingproxy_get(mappingproxyobject *pp, PyObject *const *args, Py_ssize_t nargs) +mappingproxy_get(PyObject *self, PyObject *const *args, Py_ssize_t nargs) { + mappingproxyobject *pp = (mappingproxyobject *)self; /* newargs: mapping, key, default=None */ PyObject *newargs[3]; newargs[0] = pp->mapping;