From 31f6b8f55f2a53445154abdf5c1aa3ca07ca36ad Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:34:47 -0600 Subject: [PATCH 01/26] 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 0bfd8d4cac8d9773e30b3ef0fad245844de60a65 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:38:09 -0600 Subject: [PATCH 02/26] 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 3514d30cbe0b6dc77a1a736d5a71e55c1830a1c5 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:41:43 -0600 Subject: [PATCH 03/26] 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 166c6c67e473a423ec681abcb09d0c98a8789939 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 01:46:44 -0600 Subject: [PATCH 04/26] 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 967509999e8722b08c382d32ed1e49c8a7cb8ef6 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:41:22 -0600 Subject: [PATCH 05/26] 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 08423ce253b531e6e8d9200049c5391179496efe Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:52:16 -0600 Subject: [PATCH 06/26] 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 e5c70b4462d31679b8d48cd60c390185663cef91 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 05:04:15 -0600 Subject: [PATCH 07/26] 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 3f321023bbb71f517532159a9ffe01aa51a3d9f6 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 21:29:24 -0600 Subject: [PATCH 08/26] 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 136415badf2f5f40ab92e6b138a2ed6a18f844d6 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 21:53:40 -0600 Subject: [PATCH 09/26] 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 7fc9eaf6032f6fd1859f82300f5aff03a6685810 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 05:13:03 -0600 Subject: [PATCH 10/26] 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 5dbaa7e403c343a7068b7fd168cd74da555aedc7 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:39:03 -0600 Subject: [PATCH 11/26] 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 825867b1f021ea2a335cb892b3a22d3c5ef08ed9 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:41:11 -0600 Subject: [PATCH 12/26] 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 77927e5b10a05f812a51a17ba42a8828dbf92032 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:43:28 -0600 Subject: [PATCH 13/26] 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 6dd42367cca26e85c0f420846cecff669a142612 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:46:54 -0600 Subject: [PATCH 14/26] 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 8b6babfe931ba40eed44855542789f0976bc3df9 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:49:32 -0600 Subject: [PATCH 15/26] 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 e20d180288ffcd16378683786d0cbb7e286913fe Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:51:38 -0600 Subject: [PATCH 16/26] 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 aceb958b20f6c8b631ac6a53ead505818458d43e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:55:25 -0600 Subject: [PATCH 17/26] 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 05320447a1f1479030c522f4117c6903ba6323d3 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:57:46 -0600 Subject: [PATCH 18/26] 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 7ef54809ad3d896d6691d4f757e2b1926844705d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 18:59:51 -0600 Subject: [PATCH 19/26] 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 6445fc67a9014733605930116a885ce16137a178 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:04:36 -0600 Subject: [PATCH 20/26] 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 fc9fccb54ff600c70e3ade79daac8127abda4a4e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:07:32 -0600 Subject: [PATCH 21/26] 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 2dd66851ceb0d39c2c7fb1cd0c6115b84835297c Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:08:34 -0600 Subject: [PATCH 22/26] 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 bf28e3eaa0932228c747687818a71a44761e5e62 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:13:00 -0600 Subject: [PATCH 23/26] 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 15f1bfc570e0ae6fe69f2fa1676ae5eac7d10e4a Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:15:35 -0600 Subject: [PATCH 24/26] 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 720c908e2cbb6aa09a4f28098001698f91714036 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:24:35 -0600 Subject: [PATCH 25/26] 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 d2bea5b065d36f54262e4a3009dfb28f6a2a08ea Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Wed, 6 Dec 2023 19:35:29 -0600 Subject: [PATCH 26/26] 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;