diff options
author | Victor Stinner <vstinner@python.org> | 2022-05-03 19:42:14 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-05-03 19:42:14 (GMT) |
commit | 804f2529d8e545a8d59eaf260ee032d014e681ba (patch) | |
tree | aab0f479960e57753df3789313363dd0e3e6bafc /Objects | |
parent | 551d02b3e697098236bb3a6e0a855b2ad8dc0424 (diff) | |
download | cpython-804f2529d8e545a8d59eaf260ee032d014e681ba.zip cpython-804f2529d8e545a8d59eaf260ee032d014e681ba.tar.gz cpython-804f2529d8e545a8d59eaf260ee032d014e681ba.tar.bz2 |
gh-91320: Use _PyCFunction_CAST() (#92251)
Replace "(PyCFunction)(void(*)(void))func" cast with
_PyCFunction_CAST(func).
Change generated by the command:
sed -i -e \
's!(PyCFunction)(void(\*)(void)) *\([A-Za-z0-9_]\+\)!_PyCFunction_CAST(\1)!g' \
$(find -name "*.c")
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/descrobject.c | 2 | ||||
-rw-r--r-- | Objects/dictobject.c | 12 | ||||
-rw-r--r-- | Objects/genobject.c | 10 | ||||
-rw-r--r-- | Objects/odictobject.c | 2 | ||||
-rw-r--r-- | Objects/typeobject.c | 6 | ||||
-rw-r--r-- | Objects/unicodeobject.c | 2 |
6 files changed, 17 insertions, 17 deletions
diff --git a/Objects/descrobject.c b/Objects/descrobject.c index 7cbfe8d..9cc76cf 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -1145,7 +1145,7 @@ mappingproxy_reversed(mappingproxyobject *pp, PyObject *Py_UNUSED(ignored)) to the underlying mapping */ static PyMethodDef mappingproxy_methods[] = { - {"get", (PyCFunction)(void(*)(void))mappingproxy_get, METH_FASTCALL, + {"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, diff --git a/Objects/dictobject.c b/Objects/dictobject.c index 88addfd..8a93ae9 100644 --- a/Objects/dictobject.c +++ b/Objects/dictobject.c @@ -3655,9 +3655,9 @@ PyDoc_STRVAR(values__doc__, static PyMethodDef mapp_methods[] = { DICT___CONTAINS___METHODDEF - {"__getitem__", (PyCFunction)(void(*)(void))dict_subscript, METH_O | METH_COEXIST, + {"__getitem__", _PyCFunction_CAST(dict_subscript), METH_O | METH_COEXIST, getitem__doc__}, - {"__sizeof__", (PyCFunction)(void(*)(void))dict_sizeof, METH_NOARGS, + {"__sizeof__", _PyCFunction_CAST(dict_sizeof), METH_NOARGS, sizeof__doc__}, DICT_GET_METHODDEF DICT_SETDEFAULT_METHODDEF @@ -3669,7 +3669,7 @@ static PyMethodDef mapp_methods[] = { items__doc__}, {"values", dictvalues_new, METH_NOARGS, values__doc__}, - {"update", (PyCFunction)(void(*)(void))dict_update, METH_VARARGS | METH_KEYWORDS, + {"update", _PyCFunction_CAST(dict_update), METH_VARARGS | METH_KEYWORDS, update__doc__}, DICT_FROMKEYS_METHODDEF {"clear", (PyCFunction)dict_clear, METH_NOARGS, @@ -4026,9 +4026,9 @@ dictiter_reduce(dictiterobject *di, PyObject *Py_UNUSED(ignored)); PyDoc_STRVAR(reduce_doc, "Return state information for pickling."); static PyMethodDef dictiter_methods[] = { - {"__length_hint__", (PyCFunction)(void(*)(void))dictiter_len, METH_NOARGS, + {"__length_hint__", _PyCFunction_CAST(dictiter_len), METH_NOARGS, length_hint_doc}, - {"__reduce__", (PyCFunction)(void(*)(void))dictiter_reduce, METH_NOARGS, + {"__reduce__", _PyCFunction_CAST(dictiter_reduce), METH_NOARGS, reduce_doc}, {NULL, NULL} /* sentinel */ }; @@ -5079,7 +5079,7 @@ PyDoc_STRVAR(reversed_keys_doc, static PyMethodDef dictkeys_methods[] = { {"isdisjoint", (PyCFunction)dictviews_isdisjoint, METH_O, isdisjoint_doc}, - {"__reversed__", (PyCFunction)(void(*)(void))dictkeys_reversed, METH_NOARGS, + {"__reversed__", _PyCFunction_CAST(dictkeys_reversed), METH_NOARGS, reversed_keys_doc}, {NULL, NULL} /* sentinel */ }; diff --git a/Objects/genobject.c b/Objects/genobject.c index 7920a10..0a4b43e 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -821,7 +821,7 @@ PyDoc_STRVAR(sizeof__doc__, static PyMethodDef gen_methods[] = { {"send",(PyCFunction)gen_send, METH_O, send_doc}, - {"throw",(PyCFunction)(void(*)(void))gen_throw, METH_FASTCALL, throw_doc}, + {"throw",_PyCFunction_CAST(gen_throw), METH_FASTCALL, throw_doc}, {"close",(PyCFunction)gen_close, METH_NOARGS, close_doc}, {"__sizeof__", (PyCFunction)gen_sizeof, METH_NOARGS, sizeof__doc__}, {NULL, NULL} /* Sentinel */ @@ -1169,7 +1169,7 @@ PyDoc_STRVAR(coro_close_doc, static PyMethodDef coro_methods[] = { {"send",(PyCFunction)gen_send, METH_O, coro_send_doc}, - {"throw",(PyCFunction)(void(*)(void))gen_throw, METH_FASTCALL, coro_throw_doc}, + {"throw",_PyCFunction_CAST(gen_throw), METH_FASTCALL, coro_throw_doc}, {"close",(PyCFunction)gen_close, METH_NOARGS, coro_close_doc}, {"__sizeof__", (PyCFunction)gen_sizeof, METH_NOARGS, sizeof__doc__}, {NULL, NULL} /* Sentinel */ @@ -1276,7 +1276,7 @@ coro_wrapper_traverse(PyCoroWrapper *cw, visitproc visit, void *arg) static PyMethodDef coro_wrapper_methods[] = { {"send",(PyCFunction)coro_wrapper_send, METH_O, coro_send_doc}, - {"throw",(PyCFunction)(void(*)(void))coro_wrapper_throw, + {"throw",_PyCFunction_CAST(coro_wrapper_throw), METH_FASTCALL, coro_throw_doc}, {"close",(PyCFunction)coro_wrapper_close, METH_NOARGS, coro_close_doc}, {NULL, NULL} /* Sentinel */ @@ -1831,7 +1831,7 @@ async_gen_asend_close(PyAsyncGenASend *o, PyObject *args) static PyMethodDef async_gen_asend_methods[] = { {"send", (PyCFunction)async_gen_asend_send, METH_O, send_doc}, - {"throw", (PyCFunction)(void(*)(void))async_gen_asend_throw, METH_FASTCALL, throw_doc}, + {"throw", _PyCFunction_CAST(async_gen_asend_throw), METH_FASTCALL, throw_doc}, {"close", (PyCFunction)async_gen_asend_close, METH_NOARGS, close_doc}, {NULL, NULL} /* Sentinel */ }; @@ -2248,7 +2248,7 @@ async_gen_athrow_close(PyAsyncGenAThrow *o, PyObject *args) static PyMethodDef async_gen_athrow_methods[] = { {"send", (PyCFunction)async_gen_athrow_send, METH_O, send_doc}, - {"throw", (PyCFunction)(void(*)(void))async_gen_athrow_throw, + {"throw", _PyCFunction_CAST(async_gen_athrow_throw), METH_FASTCALL, throw_doc}, {"close", (PyCFunction)async_gen_athrow_close, METH_NOARGS, close_doc}, {NULL, NULL} /* Sentinel */ diff --git a/Objects/odictobject.c b/Objects/odictobject.c index f5b8b3e..bd2a767 100644 --- a/Objects/odictobject.c +++ b/Objects/odictobject.c @@ -1317,7 +1317,7 @@ static PyMethodDef odict_methods[] = { odict_values__doc__}, {"items", odictitems_new, METH_NOARGS, odict_items__doc__}, - {"update", (PyCFunction)(void(*)(void))odict_update, METH_VARARGS | METH_KEYWORDS, + {"update", _PyCFunction_CAST(odict_update), METH_VARARGS | METH_KEYWORDS, odict_update__doc__}, {"clear", (PyCFunction)odict_clear, METH_NOARGS, odict_clear__doc__}, diff --git a/Objects/typeobject.c b/Objects/typeobject.c index f529e18..4afaf24 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4289,7 +4289,7 @@ type___sizeof___impl(PyTypeObject *self) static PyMethodDef type_methods[] = { TYPE_MRO_METHODDEF TYPE___SUBCLASSES___METHODDEF - {"__prepare__", (PyCFunction)(void(*)(void))type_prepare, + {"__prepare__", _PyCFunction_CAST(type_prepare), METH_FASTCALL | METH_KEYWORDS | METH_CLASS, PyDoc_STR("__prepare__() -> dict\n" "used to create the namespace for the class statement")}, @@ -7141,7 +7141,7 @@ tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds) } static struct PyMethodDef tp_new_methoddef[] = { - {"__new__", (PyCFunction)(void(*)(void))tp_new_wrapper, METH_VARARGS|METH_KEYWORDS, + {"__new__", _PyCFunction_CAST(tp_new_wrapper), METH_VARARGS|METH_KEYWORDS, PyDoc_STR("__new__($type, *args, **kwargs)\n--\n\n" "Create and return a new object. " "See help(type) for accurate signature.")}, @@ -8390,7 +8390,7 @@ update_one_slot(PyTypeObject *type, slotdef *p) } else if (Py_IS_TYPE(descr, &PyCFunction_Type) && PyCFunction_GET_FUNCTION(descr) == - (PyCFunction)(void(*)(void))tp_new_wrapper && + _PyCFunction_CAST(tp_new_wrapper) && ptr == (void**)&type->tp_new) { /* The __new__ wrapper is not a wrapper descriptor, diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 36a5296..656c7cc 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -14214,7 +14214,7 @@ static PyMethodDef unicode_methods[] = { UNICODE_ISIDENTIFIER_METHODDEF UNICODE_ISPRINTABLE_METHODDEF UNICODE_ZFILL_METHODDEF - {"format", (PyCFunction)(void(*)(void)) do_string_format, METH_VARARGS | METH_KEYWORDS, format__doc__}, + {"format", _PyCFunction_CAST(do_string_format), METH_VARARGS | METH_KEYWORDS, format__doc__}, {"format_map", (PyCFunction) do_string_format_map, METH_O, format_map__doc__}, UNICODE___FORMAT___METHODDEF UNICODE_MAKETRANS_METHODDEF |