From e9c0f5f0460675f87e737b6dd9608ff1ad3150c5 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 03:55:52 -0600 Subject: [PATCH 01/49] 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 31f6c0791fb04271d40120681c881a5016e68fa8 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:12:27 -0600 Subject: [PATCH 02/49] 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 b950d1a65d1ef215bfe50cd6353d92944e258b33 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:23:57 -0600 Subject: [PATCH 03/49] 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 505a00c28e471a8f0e87152bdb7b0196b08452f0 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 04:30:33 -0600 Subject: [PATCH 04/49] 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 2e1b409df7138820b976cb2fc3918b099bd173a9 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 21:15:28 -0600 Subject: [PATCH 05/49] 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 b82d04883f749551642c587fe8437beed24fbeb3 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Mon, 4 Dec 2023 22:07:01 -0600 Subject: [PATCH 06/49] 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 eb6c22ed209b9486cb42f1d33592fc036e05aac8 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 17:00:40 -0600 Subject: [PATCH 07/49] 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 60c0d7a08aededcbf9e59810da67280a1ff0fb2b Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 17:02:30 -0600 Subject: [PATCH 08/49] 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 1de5a1aca209898d574c1bd6a3d6072cc83c3a4f Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:31:49 -0600 Subject: [PATCH 09/49] 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 8b57573e584a992735956690d23a5a2b6c8fa718 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:39:20 -0600 Subject: [PATCH 10/49] 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 d2f06e6f2c10849c54e6e80a6fbc05039cf1a245 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:41:29 -0600 Subject: [PATCH 11/49] 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 4cd2e6d62180047f5aec85832c6cbb756bc7240f Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:42:31 -0600 Subject: [PATCH 12/49] 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 f32c9e0c6b400424059e5c14958fe4395a41af35 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:43:56 -0600 Subject: [PATCH 13/49] 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 83df0df8ed7251512d75f00ea6119fec202d1672 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:45:46 -0600 Subject: [PATCH 14/49] 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 a4c7f17b3ba387296f5d756edadb93a8c01c2d3a Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:49:14 -0600 Subject: [PATCH 15/49] 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 be0fb74fea26dc2ea41f79ebb1843ac57d2c905d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:52:09 -0600 Subject: [PATCH 16/49] 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 356c2fe91476e141f638dc456c10b8145fc11ea1 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:53:53 -0600 Subject: [PATCH 17/49] 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 ec4ca04cf3ab16b23d33db0a813547fb12d94aaf Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 18:54:55 -0600 Subject: [PATCH 18/49] 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 9ebb68f19292cffeaaf8eb83256764d766474b80 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:05:37 -0600 Subject: [PATCH 19/49] 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 de9918935ec85b504afbbc0ee5182168594907d6 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:06:55 -0600 Subject: [PATCH 20/49] 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 9b43a8d73e29a0d32f3bb811790e7b556ee80000 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:07:36 -0600 Subject: [PATCH 21/49] 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 32b8dfe7bfd624aab251506beaea086670486635 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:54:44 -0600 Subject: [PATCH 22/49] 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 78419d63b11adfed1e1c60fa2eb310cff9c0f7ab Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:54:57 -0600 Subject: [PATCH 23/49] 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 97d3ee8509017e0c116b93aa42f36f86b3bc090e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:57:43 -0600 Subject: [PATCH 24/49] 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 30cd173a21815c2cfdf45c84c60a7ac68ec8aff7 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:58:14 -0600 Subject: [PATCH 25/49] 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 fcce5659720ee256271d7b9cec2a3556572d7178 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:58:57 -0600 Subject: [PATCH 26/49] 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 776acd7ebc84ee57dc8bb1c33a6e484417f9a606 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 19:59:50 -0600 Subject: [PATCH 27/49] 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 f4dfb12e79ccf97a066324fa42d0c4809608c51c Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:01:12 -0600 Subject: [PATCH 28/49] 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 80da821192a79e7a68721d9ddc544d451a1a40fd Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:02:13 -0600 Subject: [PATCH 29/49] Remove redundant 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 7b903ea6d0e91143903cc42cab82016783e9d937 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:15:10 -0600 Subject: [PATCH 30/49] 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 d646a9decec7b93ea8bc3a43fc826f571c406e98 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:17:45 -0600 Subject: [PATCH 31/49] 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 75a49808f39a2ddfbb2159a7fd1207afd3580e2e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:19:27 -0600 Subject: [PATCH 32/49] 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 e96377d280f852328f11f222118d66efb5b30be7 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:20:01 -0600 Subject: [PATCH 33/49] 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 0002cba2d8bc009bd7599e68a33b21185c3ebb1c Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:20:41 -0600 Subject: [PATCH 34/49] 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 057c05916ae30e348922c97a7a2b322165d5bc76 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:21:12 -0600 Subject: [PATCH 35/49] 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 57224d09c54fea9ab36181c2d1ceea0b43535ae1 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:21:42 -0600 Subject: [PATCH 36/49] 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 071d2bc200163f43d9fb09fedab9138c590bb2d9 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:23:54 -0600 Subject: [PATCH 37/49] 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 65f0a905a97c00c6755b05b72ba3a3ea5c4f1cf8 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 20:24:41 -0600 Subject: [PATCH 38/49] 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 385dbfdfec77ef8b3f2e59b6a5176044c379509d Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:25:25 -0600 Subject: [PATCH 39/49] 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 a0e0ae02e0db8ef6d123deb5f0d08ec43024641e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:31:01 -0600 Subject: [PATCH 40/49] 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 ff534a15cb7a98960315f7f7533efeed410fb4fc Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:32:03 -0600 Subject: [PATCH 41/49] 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 ae28dc111f812684431483405e35029f8a6b39ed Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:33:35 -0600 Subject: [PATCH 42/49] 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 547cbc04af60207070ef11826be3ebaf5aff809c Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:35:17 -0600 Subject: [PATCH 43/49] 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 6360a467a829a415a4dc08fb68c5d272f94efc92 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:37:11 -0600 Subject: [PATCH 44/49] 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 e823bed89def2ee7701ecb7939cc91643e63d303 Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:37:46 -0600 Subject: [PATCH 45/49] 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 6c15c763d76c6814fdccd6718ee6ad1569a8c57c Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:39:15 -0600 Subject: [PATCH 46/49] 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 238724f0cc11d344f63d14def84ee7c91981719b Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Thu, 7 Dec 2023 21:41:10 -0600 Subject: [PATCH 47/49] 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 cb6f751a58e76c4304929833cb0e7489cce72bda Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Fri, 8 Dec 2023 02:23:35 -0600 Subject: [PATCH 48/49] 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 dd6428077010d80e08b4a9ead220a7d41471cb7e Mon Sep 17 00:00:00 2001 From: Christopher Chavez Date: Fri, 8 Dec 2023 20:47:24 -0600 Subject: [PATCH 49/49] 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;