https://github.com/python/cpython/commit/edbf7fb1298d4c4a0b1a820b7d4094d74a395188
commit: edbf7fb1298d4c4a0b1a820b7d4094d74a395188
branch: main
author: Bénédikt Tran <10796600+picn...@users.noreply.github.com>
committer: picnixz <10796600+picn...@users.noreply.github.com>
date: 2025-04-01T17:18:11+02:00
summary:

gh-111178: remove redundant casts for functions with correct signatures 
(#131673)

files:
M Modules/_asynciomodule.c
M Modules/_cursesmodule.c
M Modules/_functoolsmodule.c
M Modules/_interpchannelsmodule.c
M Modules/_io/textio.c
M Modules/_io/winconsoleio.c
M Modules/_lzmamodule.c
M Modules/_testcapi/docstring.c
M Modules/_testcapi/exceptions.c
M Modules/_testcapi/gc.c
M Modules/_testcapi/mem.c
M Modules/_testcapi/watchers.c
M Modules/_testinternalcapi.c
M Modules/_xxtestfuzz/_xxtestfuzz.c
M Modules/_zoneinfo.c
M Modules/atexitmodule.c
M Modules/cjkcodecs/cjkcodecs.h
M Modules/faulthandler.c
M Objects/boolobject.c
M Objects/bytearrayobject.c
M Objects/dictobject.c
M Objects/genericaliasobject.c
M Objects/listobject.c
M Objects/longobject.c
M Objects/object.c
M Objects/rangeobject.c
M Objects/stringlib/unicode_format.h
M Objects/unicodeobject.c
M Objects/unionobject.c
M Python/hamt.c

diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 28234c4f902a34..d938955e8cb0e3 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -2956,7 +2956,7 @@ static PyType_Slot Task_slots[] = {
     {Py_tp_iter, future_new_iter},
     {Py_tp_methods, TaskType_methods},
     {Py_tp_getset, TaskType_getsetlist},
-    {Py_tp_init, (initproc)_asyncio_Task___init__},
+    {Py_tp_init, _asyncio_Task___init__},
     {Py_tp_new, PyType_GenericNew},
     {Py_tp_finalize, TaskObj_finalize},
 
@@ -4396,7 +4396,7 @@ static struct PyModuleDef _asynciomodule = {
     .m_slots = module_slots,
     .m_traverse = module_traverse,
     .m_clear = module_clear,
-    .m_free = (freefunc)module_free,
+    .m_free = module_free,
 };
 
 PyMODINIT_FUNC
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index 2025724953969b..bf18cb51605075 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -2709,7 +2709,7 @@ static PyMethodDef PyCursesWindow_methods[] = {
     _CURSES_WINDOW_SETSCRREG_METHODDEF
     {"standend",        PyCursesWindow_wstandend, METH_NOARGS},
     {"standout",        PyCursesWindow_wstandout, METH_NOARGS},
-    {"subpad", (PyCFunction)_curses_window_subwin, METH_VARARGS, 
_curses_window_subwin__doc__},
+    {"subpad",          _curses_window_subwin, METH_VARARGS, 
_curses_window_subwin__doc__},
     _CURSES_WINDOW_SUBWIN_METHODDEF
     {"syncdown",        PyCursesWindow_wsyncdown, METH_NOARGS},
 #ifdef HAVE_CURSES_SYNCOK
diff --git a/Modules/_functoolsmodule.c b/Modules/_functoolsmodule.c
index 2529a9047f3299..c84779268eb12e 100644
--- a/Modules/_functoolsmodule.c
+++ b/Modules/_functoolsmodule.c
@@ -1634,19 +1634,19 @@ _functools__lru_cache_wrapper_cache_clear_impl(PyObject 
*self)
 }
 
 static PyObject *
-lru_cache_reduce(PyObject *self, PyObject *unused)
+lru_cache_reduce(PyObject *self, PyObject *Py_UNUSED(dummy))
 {
     return PyObject_GetAttrString(self, "__qualname__");
 }
 
 static PyObject *
-lru_cache_copy(PyObject *self, PyObject *unused)
+lru_cache_copy(PyObject *self, PyObject *Py_UNUSED(args))
 {
     return Py_NewRef(self);
 }
 
 static PyObject *
-lru_cache_deepcopy(PyObject *self, PyObject *unused)
+lru_cache_deepcopy(PyObject *self, PyObject *Py_UNUSED(args))
 {
     return Py_NewRef(self);
 }
@@ -1693,9 +1693,9 @@ cache_info_type:    namedtuple class with the fields:\n\
 static PyMethodDef lru_cache_methods[] = {
     _FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_INFO_METHODDEF
     _FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_CLEAR_METHODDEF
-    {"__reduce__", (PyCFunction)lru_cache_reduce, METH_NOARGS},
-    {"__copy__", (PyCFunction)lru_cache_copy, METH_VARARGS},
-    {"__deepcopy__", (PyCFunction)lru_cache_deepcopy, METH_VARARGS},
+    {"__reduce__", lru_cache_reduce, METH_NOARGS},
+    {"__copy__", lru_cache_copy, METH_VARARGS},
+    {"__deepcopy__", lru_cache_deepcopy, METH_VARARGS},
     {NULL}
 };
 
diff --git a/Modules/_interpchannelsmodule.c b/Modules/_interpchannelsmodule.c
index ae64037d56cac0..6cc1a5b828627f 100644
--- a/Modules/_interpchannelsmodule.c
+++ b/Modules/_interpchannelsmodule.c
@@ -3595,7 +3595,7 @@ static struct PyModuleDef moduledef = {
     .m_slots = module_slots,
     .m_traverse = module_traverse,
     .m_clear = module_clear,
-    .m_free = (freefunc)module_free,
+    .m_free = module_free,
 };
 
 PyMODINIT_FUNC
diff --git a/Modules/_io/textio.c b/Modules/_io/textio.c
index 377c85f5ac67a6..e77d8448310fba 100644
--- a/Modules/_io/textio.c
+++ b/Modules/_io/textio.c
@@ -3386,8 +3386,6 @@ static PyMemberDef textiowrapper_members[] = {
 static PyGetSetDef textiowrapper_getset[] = {
     _IO_TEXTIOWRAPPER_NAME_GETSETDEF
     _IO_TEXTIOWRAPPER_CLOSED_GETSETDEF
-/*    {"mode", (getter)TextIOWrapper_mode_get, NULL, NULL},
-*/
     _IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF
     _IO_TEXTIOWRAPPER_ERRORS_GETSETDEF
     _IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF
diff --git a/Modules/_io/winconsoleio.c b/Modules/_io/winconsoleio.c
index 77fe5259e4af1e..3e783b9da45652 100644
--- a/Modules/_io/winconsoleio.c
+++ b/Modules/_io/winconsoleio.c
@@ -1195,7 +1195,7 @@ static PyMethodDef winconsoleio_methods[] = {
     _IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF
     _IO__WINDOWSCONSOLEIO_FILENO_METHODDEF
     _IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
-    {"_isatty_open_only", (PyCFunction)_io__WindowsConsoleIO_isatty, 
METH_NOARGS},
+    {"_isatty_open_only", _io__WindowsConsoleIO_isatty, METH_NOARGS},
     {NULL,           NULL}             /* sentinel */
 };
 
diff --git a/Modules/_lzmamodule.c b/Modules/_lzmamodule.c
index 0058e2eec2ef16..c05cc8a4e4cb49 100644
--- a/Modules/_lzmamodule.c
+++ b/Modules/_lzmamodule.c
@@ -1410,7 +1410,7 @@ PyDoc_STRVAR(_lzma__encode_filter_properties__doc__,
 "The result does not include the filter ID itself, only the options.");
 
 #define _LZMA__ENCODE_FILTER_PROPERTIES_METHODDEF    \
-    {"_encode_filter_properties", 
(PyCFunction)_lzma__encode_filter_properties, METH_O, 
_lzma__encode_filter_properties__doc__},
+    {"_encode_filter_properties", _lzma__encode_filter_properties, METH_O, 
_lzma__encode_filter_properties__doc__},
 
 static PyObject *
 _lzma__encode_filter_properties_impl(PyObject *module, lzma_filter filter);
diff --git a/Modules/_testcapi/docstring.c b/Modules/_testcapi/docstring.c
index 3f7acbae1b181b..efb889cba8796e 100644
--- a/Modules/_testcapi/docstring.c
+++ b/Modules/_testcapi/docstring.c
@@ -66,42 +66,42 @@ test_with_docstring(PyObject *self, PyObject 
*Py_UNUSED(ignored))
 
 static PyMethodDef test_methods[] = {
     {"docstring_empty",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         docstring_empty},
     {"docstring_no_signature",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         docstring_no_signature},
     {"docstring_no_signature_noargs",
-        (PyCFunction)test_with_docstring, METH_NOARGS,
+        test_with_docstring, METH_NOARGS,
         docstring_no_signature},
     {"docstring_no_signature_o",
-        (PyCFunction)test_with_docstring, METH_O,
+        test_with_docstring, METH_O,
         docstring_no_signature},
     {"docstring_with_invalid_signature",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         docstring_with_invalid_signature},
     {"docstring_with_invalid_signature2",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         docstring_with_invalid_signature2},
     {"docstring_with_signature",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         docstring_with_signature},
     {"docstring_with_signature_and_extra_newlines",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         docstring_with_signature_and_extra_newlines},
     {"docstring_with_signature_but_no_doc",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         docstring_with_signature_but_no_doc},
     {"docstring_with_signature_with_defaults",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         docstring_with_signature_with_defaults},
     {"no_docstring",
-        (PyCFunction)test_with_docstring, METH_VARARGS},
+        test_with_docstring, METH_VARARGS},
     {"test_with_docstring",
         test_with_docstring,              METH_VARARGS,
         PyDoc_STR("This is a pretty normal docstring.")},
     {"func_with_unrepresentable_signature",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         PyDoc_STR(
             "func_with_unrepresentable_signature($module, /, a, b=<x>)\n"
             "--\n\n"
@@ -112,28 +112,28 @@ static PyMethodDef test_methods[] = {
 
 static PyMethodDef DocStringNoSignatureTest_methods[] = {
     {"meth_noargs",
-        (PyCFunction)test_with_docstring, METH_NOARGS,
+        test_with_docstring, METH_NOARGS,
         docstring_no_signature},
     {"meth_o",
-        (PyCFunction)test_with_docstring, METH_O,
+        test_with_docstring, METH_O,
         docstring_no_signature},
     {"meth_noargs_class",
-        (PyCFunction)test_with_docstring, METH_NOARGS|METH_CLASS,
+        test_with_docstring, METH_NOARGS|METH_CLASS,
         docstring_no_signature},
     {"meth_o_class",
-        (PyCFunction)test_with_docstring, METH_O|METH_CLASS,
+        test_with_docstring, METH_O|METH_CLASS,
         docstring_no_signature},
     {"meth_noargs_static",
-        (PyCFunction)test_with_docstring, METH_NOARGS|METH_STATIC,
+        test_with_docstring, METH_NOARGS|METH_STATIC,
         docstring_no_signature},
     {"meth_o_static",
-        (PyCFunction)test_with_docstring, METH_O|METH_STATIC,
+        test_with_docstring, METH_O|METH_STATIC,
         docstring_no_signature},
     {"meth_noargs_coexist",
-        (PyCFunction)test_with_docstring, METH_NOARGS|METH_COEXIST,
+        test_with_docstring, METH_NOARGS|METH_COEXIST,
         docstring_no_signature},
     {"meth_o_coexist",
-        (PyCFunction)test_with_docstring, METH_O|METH_COEXIST,
+        test_with_docstring, METH_O|METH_COEXIST,
         docstring_no_signature},
     {NULL},
 };
@@ -149,28 +149,28 @@ static PyTypeObject DocStringNoSignatureTest = {
 
 static PyMethodDef DocStringUnrepresentableSignatureTest_methods[] = {
     {"meth",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         PyDoc_STR(
             "meth($self, /, a, b=<x>)\n"
             "--\n\n"
             "This docstring has a signature with unrepresentable default."
         )},
     {"classmeth",
-        (PyCFunction)test_with_docstring, METH_VARARGS|METH_CLASS,
+        test_with_docstring, METH_VARARGS|METH_CLASS,
         PyDoc_STR(
             "classmeth($type, /, a, b=<x>)\n"
             "--\n\n"
             "This docstring has a signature with unrepresentable default."
         )},
     {"staticmeth",
-        (PyCFunction)test_with_docstring, METH_VARARGS|METH_STATIC,
+        test_with_docstring, METH_VARARGS|METH_STATIC,
         PyDoc_STR(
             "staticmeth(a, b=<x>)\n"
             "--\n\n"
             "This docstring has a signature with unrepresentable default."
         )},
     {"with_default",
-        (PyCFunction)test_with_docstring, METH_VARARGS,
+        test_with_docstring, METH_VARARGS,
         PyDoc_STR(
             "with_default($self, /, x=ONE)\n"
             "--\n\n"
diff --git a/Modules/_testcapi/exceptions.c b/Modules/_testcapi/exceptions.c
index b647bfc71eae24..0604b413e33f61 100644
--- a/Modules/_testcapi/exceptions.c
+++ b/Modules/_testcapi/exceptions.c
@@ -538,7 +538,7 @@ static PyTypeObject PyRecursingInfinitelyError_Type = {
     .tp_basicsize = sizeof(PyBaseExceptionObject),
     .tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
     .tp_doc = PyDoc_STR("Instantiating this exception starts infinite 
recursion."),
-    .tp_init = (initproc)recurse_infinitely_error_init,
+    .tp_init = recurse_infinitely_error_init,
 };
 
 static PyMethodDef test_methods[] = {
diff --git a/Modules/_testcapi/gc.c b/Modules/_testcapi/gc.c
index 3691796302e500..863cb52980f942 100644
--- a/Modules/_testcapi/gc.c
+++ b/Modules/_testcapi/gc.c
@@ -265,7 +265,7 @@ obj_extra_data_set(PyObject *self, PyObject *newval, void 
*Py_UNUSED(ignored))
 }
 
 static PyGetSetDef obj_extra_data_getset[] = {
-    {"extra", (getter)obj_extra_data_get, (setter)obj_extra_data_set, NULL},
+    {"extra", obj_extra_data_get, obj_extra_data_set, NULL},
     {NULL}
 };
 
diff --git a/Modules/_testcapi/mem.c b/Modules/_testcapi/mem.c
index 7237fb94c3f51f..b4896f984510bd 100644
--- a/Modules/_testcapi/mem.c
+++ b/Modules/_testcapi/mem.c
@@ -691,7 +691,7 @@ static PyMethodDef test_methods[] = {
     {"pyobject_malloc_without_gil",   pyobject_malloc_without_gil,   
METH_NOARGS},
     {"remove_mem_hooks",              remove_mem_hooks,              
METH_NOARGS,
         PyDoc_STR("Remove memory hooks.")},
-    {"set_nomemory",                  (PyCFunction)set_nomemory,     
METH_VARARGS,
+    {"set_nomemory",                  set_nomemory,                  
METH_VARARGS,
         PyDoc_STR("set_nomemory(start:int, stop:int = 0)")},
     {"test_pymem_alloc0",             test_pymem_alloc0,             
METH_NOARGS},
     {"test_pymem_setallocators",      test_pymem_setallocators,      
METH_NOARGS},
diff --git a/Modules/_testcapi/watchers.c b/Modules/_testcapi/watchers.c
index 6a5136ef8c9ecc..6d061bb8d51040 100644
--- a/Modules/_testcapi/watchers.c
+++ b/Modules/_testcapi/watchers.c
@@ -413,7 +413,7 @@ get_code_watcher_num_destroyed_events(PyObject *self, 
PyObject *watcher_id)
 }
 
 static PyObject *
-allocate_too_many_code_watchers(PyObject *self, PyObject *args)
+allocate_too_many_code_watchers(PyObject *self, PyObject *Py_UNUSED(args))
 {
     int watcher_ids[CODE_MAX_WATCHERS + 1];
     int num_watchers = 0;
@@ -742,7 +742,7 @@ get_context_switches(PyObject *Py_UNUSED(self), PyObject 
*watcher_id)
 }
 
 static PyObject *
-allocate_too_many_context_watchers(PyObject *self, PyObject *args)
+allocate_too_many_context_watchers(PyObject *self, PyObject *Py_UNUSED(args))
 {
     int watcher_ids[CONTEXT_MAX_WATCHERS + 1];
     int num_watchers = 0;
@@ -811,8 +811,7 @@ static PyMethodDef test_methods[] = {
     {"clear_dict_watcher",       clear_dict_watcher,      METH_O,       NULL},
     _TESTCAPI_WATCH_DICT_METHODDEF
     _TESTCAPI_UNWATCH_DICT_METHODDEF
-    {"get_dict_watcher_events",
-     (PyCFunction) get_dict_watcher_events,               METH_NOARGS,  NULL},
+    {"get_dict_watcher_events",  get_dict_watcher_events, METH_NOARGS,  NULL},
 
     // Type watchers.
     {"add_type_watcher",         add_type_watcher,        METH_O,       NULL},
@@ -820,7 +819,7 @@ static PyMethodDef test_methods[] = {
     _TESTCAPI_WATCH_TYPE_METHODDEF
     _TESTCAPI_UNWATCH_TYPE_METHODDEF
     {"get_type_modified_events",
-     (PyCFunction) get_type_modified_events,              METH_NOARGS, NULL},
+     get_type_modified_events,                            METH_NOARGS, NULL},
 
     // Code object watchers.
     {"add_code_watcher",         add_code_watcher,        METH_O,       NULL},
@@ -830,7 +829,7 @@ static PyMethodDef test_methods[] = {
     {"get_code_watcher_num_destroyed_events",
      get_code_watcher_num_destroyed_events,               METH_O,       NULL},
     {"allocate_too_many_code_watchers",
-     (PyCFunction) allocate_too_many_code_watchers,       METH_NOARGS,  NULL},
+     allocate_too_many_code_watchers,                     METH_NOARGS,  NULL},
 
     // Function watchers.
     {"add_func_watcher",         add_func_watcher,        METH_O,       NULL},
@@ -846,7 +845,7 @@ static PyMethodDef test_methods[] = {
     {"clear_context_stack",      clear_context_stack,     METH_NOARGS,  NULL},
     {"get_context_switches",     get_context_switches,    METH_O,       NULL},
     {"allocate_too_many_context_watchers",
-     (PyCFunction) allocate_too_many_context_watchers,       METH_NOARGS,  
NULL},
+     allocate_too_many_context_watchers,                  METH_NOARGS,  NULL},
     {NULL},
 };
 
diff --git a/Modules/_testinternalcapi.c b/Modules/_testinternalcapi.c
index 56e3408652a6a0..1858ce2b00c824 100644
--- a/Modules/_testinternalcapi.c
+++ b/Modules/_testinternalcapi.c
@@ -2212,7 +2212,7 @@ static struct PyModuleDef _testcapimodule = {
     .m_slots = module_slots,
     .m_traverse = module_traverse,
     .m_clear = module_clear,
-    .m_free = (freefunc)module_free,
+    .m_free = module_free,
 };
 
 
diff --git a/Modules/_xxtestfuzz/_xxtestfuzz.c 
b/Modules/_xxtestfuzz/_xxtestfuzz.c
index 2952d7043e01fe..0e0ca5f95fa449 100644
--- a/Modules/_xxtestfuzz/_xxtestfuzz.c
+++ b/Modules/_xxtestfuzz/_xxtestfuzz.c
@@ -24,7 +24,7 @@ static PyObject* _fuzz_run(PyObject* self, PyObject* args) {
 }
 
 static PyMethodDef module_methods[] = {
-    {"run", (PyCFunction)_fuzz_run, METH_VARARGS, ""},
+    {"run", _fuzz_run, METH_VARARGS, ""},
     {NULL},
 };
 
diff --git a/Modules/_zoneinfo.c b/Modules/_zoneinfo.c
index b736b7e04986d5..abd53436b21b29 100644
--- a/Modules/_zoneinfo.c
+++ b/Modules/_zoneinfo.c
@@ -2605,10 +2605,10 @@ static PyMethodDef zoneinfo_methods[] = {
     ZONEINFO_ZONEINFO_UTCOFFSET_METHODDEF
     ZONEINFO_ZONEINFO_DST_METHODDEF
     ZONEINFO_ZONEINFO_TZNAME_METHODDEF
-    {"fromutc", (PyCFunction)zoneinfo_fromutc, METH_O,
+    {"fromutc", zoneinfo_fromutc, METH_O,
      PyDoc_STR("Given a datetime with local time in UTC, retrieve an adjusted "
                "datetime in local time.")},
-    {"__reduce__", (PyCFunction)zoneinfo_reduce, METH_NOARGS,
+    {"__reduce__", zoneinfo_reduce, METH_NOARGS,
      PyDoc_STR("Function for serialization with the pickle protocol.")},
     ZONEINFO_ZONEINFO__UNPICKLE_METHODDEF
     {"__init_subclass__", _PyCFunction_CAST(zoneinfo_init_subclass),
diff --git a/Modules/atexitmodule.c b/Modules/atexitmodule.c
index 2bfdda53af8cb2..4b068967a6ca6e 100644
--- a/Modules/atexitmodule.c
+++ b/Modules/atexitmodule.c
@@ -217,7 +217,7 @@ Run all registered exit functions.\n\
 If a callback raises an exception, it is logged with sys.unraisablehook.");
 
 static PyObject *
-atexit_run_exitfuncs(PyObject *module, PyObject *unused)
+atexit_run_exitfuncs(PyObject *module, PyObject *Py_UNUSED(dummy))
 {
     struct atexit_state *state = get_atexit_state();
     atexit_callfuncs(state);
@@ -231,7 +231,7 @@ PyDoc_STRVAR(atexit_clear__doc__,
 Clear the list of previously registered exit functions.");
 
 static PyObject *
-atexit_clear(PyObject *module, PyObject *unused)
+atexit_clear(PyObject *module, PyObject *Py_UNUSED(dummy))
 {
     atexit_cleanup(get_atexit_state());
     Py_RETURN_NONE;
@@ -244,7 +244,7 @@ PyDoc_STRVAR(atexit_ncallbacks__doc__,
 Return the number of registered exit functions.");
 
 static PyObject *
-atexit_ncallbacks(PyObject *module, PyObject *unused)
+atexit_ncallbacks(PyObject *module, PyObject *Py_UNUSED(dummy))
 {
     struct atexit_state *state = get_atexit_state();
     assert(state->callbacks != NULL);
@@ -300,13 +300,11 @@ atexit_unregister(PyObject *module, PyObject *func)
 static PyMethodDef atexit_methods[] = {
     {"register", _PyCFunction_CAST(atexit_register), 
METH_VARARGS|METH_KEYWORDS,
         atexit_register__doc__},
-    {"_clear", (PyCFunction) atexit_clear, METH_NOARGS,
-        atexit_clear__doc__},
-    {"unregister", (PyCFunction) atexit_unregister, METH_O,
-        atexit_unregister__doc__},
-    {"_run_exitfuncs", (PyCFunction) atexit_run_exitfuncs, METH_NOARGS,
+    {"_clear", atexit_clear, METH_NOARGS, atexit_clear__doc__},
+    {"unregister", atexit_unregister, METH_O, atexit_unregister__doc__},
+    {"_run_exitfuncs", atexit_run_exitfuncs, METH_NOARGS,
         atexit_run_exitfuncs__doc__},
-    {"_ncallbacks", (PyCFunction) atexit_ncallbacks, METH_NOARGS,
+    {"_ncallbacks", atexit_ncallbacks, METH_NOARGS,
         atexit_ncallbacks__doc__},
     {NULL, NULL}        /* sentinel */
 };
diff --git a/Modules/cjkcodecs/cjkcodecs.h b/Modules/cjkcodecs/cjkcodecs.h
index 737a7a042753a9..f66412237011d4 100644
--- a/Modules/cjkcodecs/cjkcodecs.h
+++ b/Modules/cjkcodecs/cjkcodecs.h
@@ -495,7 +495,7 @@ _cjk_free(void *mod)
 }
 
 static struct PyMethodDef _cjk_methods[] = {
-    {"getcodec", (PyCFunction)getcodec, METH_O, ""},
+    {"getcodec", getcodec, METH_O, ""},
     {NULL, NULL},
 };
 
diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c
index ba7970d66565e5..cc5ecdcc4f96e9 100644
--- a/Modules/faulthandler.c
+++ b/Modules/faulthandler.c
@@ -1108,7 +1108,7 @@ faulthandler_fatal_error_c_thread(PyObject *self, 
PyObject *args)
 }
 
 static PyObject* _Py_NO_SANITIZE_UNDEFINED
-faulthandler_sigfpe(PyObject *self, PyObject *args)
+faulthandler_sigfpe(PyObject *self, PyObject *Py_UNUSED(dummy))
 {
     faulthandler_suppress_crash_report();
 
@@ -1274,7 +1274,7 @@ static PyMethodDef module_methods[] = {
     {"_sigabrt", faulthandler_sigabrt, METH_NOARGS,
      PyDoc_STR("_sigabrt($module, /)\n--\n\n"
                "Raise a SIGABRT signal.")},
-    {"_sigfpe", (PyCFunction)faulthandler_sigfpe, METH_NOARGS,
+    {"_sigfpe", faulthandler_sigfpe, METH_NOARGS,
      PyDoc_STR("_sigfpe($module, /)\n--\n\n"
                "Raise a SIGFPE signal.")},
 #ifdef FAULTHANDLER_STACK_OVERFLOW
diff --git a/Objects/boolobject.c b/Objects/boolobject.c
index a88a8ad0cfd560..b694691ae4d0d1 100644
--- a/Objects/boolobject.c
+++ b/Objects/boolobject.c
@@ -130,7 +130,7 @@ static PyNumberMethods bool_as_number = {
     0,                          /* nb_positive */
     0,                          /* nb_absolute */
     0,                          /* nb_bool */
-    (unaryfunc)bool_invert,     /* nb_invert */
+    bool_invert,                /* nb_invert */
     0,                          /* nb_lshift */
     0,                          /* nb_rshift */
     bool_and,                   /* nb_and */
diff --git a/Objects/bytearrayobject.c b/Objects/bytearrayobject.c
index 8f2d2dd02151c1..b5d5ca9178ebdb 100644
--- a/Objects/bytearrayobject.c
+++ b/Objects/bytearrayobject.c
@@ -2832,7 +2832,7 @@ PyTypeObject PyByteArray_Type = {
     0,                                  /* tp_descr_get */
     0,                                  /* tp_descr_set */
     0,                                  /* tp_dictoffset */
-    (initproc)bytearray___init__,       /* tp_init */
+    bytearray___init__,                 /* tp_init */
     PyType_GenericAlloc,                /* tp_alloc */
     PyType_GenericNew,                  /* tp_new */
     PyObject_Free,                      /* tp_free */
diff --git a/Objects/dictobject.c b/Objects/dictobject.c
index a290eae6464e07..ab18772d144bba 100644
--- a/Objects/dictobject.c
+++ b/Objects/dictobject.c
@@ -5927,7 +5927,7 @@ dictview_mapping(PyObject *view, void 
*Py_UNUSED(ignored)) {
 }
 
 static PyGetSetDef dictview_getset[] = {
-    {"mapping", dictview_mapping, (setter)NULL,
+    {"mapping", dictview_mapping, NULL,
      PyDoc_STR("dictionary that this view refers to"), NULL},
     {0}
 };
@@ -6344,7 +6344,7 @@ dictviews_xor(PyObject* self, PyObject *other)
 
 static PyNumberMethods dictviews_as_number = {
     0,                                  /*nb_add*/
-    (binaryfunc)dictviews_sub,          /*nb_subtract*/
+    dictviews_sub,                      /*nb_subtract*/
     0,                                  /*nb_multiply*/
     0,                                  /*nb_remainder*/
     0,                                  /*nb_divmod*/
@@ -6356,9 +6356,9 @@ static PyNumberMethods dictviews_as_number = {
     0,                                  /*nb_invert*/
     0,                                  /*nb_lshift*/
     0,                                  /*nb_rshift*/
-    (binaryfunc)_PyDictView_Intersect,  /*nb_and*/
-    (binaryfunc)dictviews_xor,          /*nb_xor*/
-    (binaryfunc)dictviews_or,           /*nb_or*/
+    _PyDictView_Intersect,              /*nb_and*/
+    dictviews_xor,                      /*nb_xor*/
+    dictviews_or,                       /*nb_or*/
 };
 
 static PyObject*
@@ -6616,7 +6616,7 @@ static PySequenceMethods dictvalues_as_sequence = {
     0,                                  /* sq_slice */
     0,                                  /* sq_ass_item */
     0,                                  /* sq_ass_slice */
-    (objobjproc)0,                      /* sq_contains */
+    0,                                  /* sq_contains */
 };
 
 static PyObject* dictvalues_reversed(PyObject *dv, PyObject 
*Py_UNUSED(ignored));
diff --git a/Objects/genericaliasobject.c b/Objects/genericaliasobject.c
index a56ed908d71133..ec3d01f00a3c3c 100644
--- a/Objects/genericaliasobject.c
+++ b/Objects/genericaliasobject.c
@@ -824,8 +824,8 @@ ga_unpacked_tuple_args(PyObject *self, void *unused)
 }
 
 static PyGetSetDef ga_properties[] = {
-    {"__parameters__", ga_parameters, (setter)NULL, PyDoc_STR("Type variables 
in the GenericAlias."), NULL},
-    {"__typing_unpacked_tuple_args__", ga_unpacked_tuple_args, (setter)NULL, 
NULL},
+    {"__parameters__", ga_parameters, NULL, PyDoc_STR("Type variables in the 
GenericAlias."), NULL},
+    {"__typing_unpacked_tuple_args__", ga_unpacked_tuple_args, NULL, NULL},
     {0}
 };
 
@@ -1000,7 +1000,7 @@ PyTypeObject Py_GenericAliasType = {
     .tp_new = ga_new,
     .tp_free = PyObject_GC_Del,
     .tp_getset = ga_properties,
-    .tp_iter = (getiterfunc)ga_iter,
+    .tp_iter = ga_iter,
     .tp_vectorcall_offset = offsetof(gaobject, vectorcall),
 };
 
diff --git a/Objects/listobject.c b/Objects/listobject.c
index 917bef1a66ddff..12d5b33414a92a 100644
--- a/Objects/listobject.c
+++ b/Objects/listobject.c
@@ -3873,7 +3873,7 @@ PyTypeObject PyList_Type = {
     0,                                          /* tp_descr_get */
     0,                                          /* tp_descr_set */
     0,                                          /* tp_dictoffset */
-    (initproc)list___init__,                    /* tp_init */
+    list___init__,                              /* tp_init */
     PyType_GenericAlloc,                        /* tp_alloc */
     PyType_GenericNew,                          /* tp_new */
     PyObject_GC_Del,                            /* tp_free */
diff --git a/Objects/longobject.c b/Objects/longobject.c
index d0c3bb145ac28d..692312c1ad976c 100644
--- a/Objects/longobject.c
+++ b/Objects/longobject.c
@@ -6540,19 +6540,19 @@ static PyMethodDef long_methods[] = {
 
 static PyGetSetDef long_getset[] = {
     {"real",
-     long_long_getter, (setter)NULL,
+     long_long_getter, NULL,
      "the real part of a complex number",
      NULL},
     {"imag",
-     long_get0, (setter)NULL,
+     long_get0, NULL,
      "the imaginary part of a complex number",
      NULL},
     {"numerator",
-     long_long_getter, (setter)NULL,
+     long_long_getter, NULL,
      "the numerator of a rational number in lowest terms",
      NULL},
     {"denominator",
-     long_get1, (setter)NULL,
+     long_get1, NULL,
      "the denominator of a rational number in lowest terms",
      NULL},
     {NULL}  /* Sentinel */
diff --git a/Objects/object.c b/Objects/object.c
index 974cf609cfccb4..457ff17b980e75 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -2106,7 +2106,7 @@ static PyNumberMethods none_as_number = {
     0,                          /* nb_negative */
     0,                          /* nb_positive */
     0,                          /* nb_absolute */
-    (inquiry)none_bool,         /* nb_bool */
+    none_bool,                  /* nb_bool */
     0,                          /* nb_invert */
     0,                          /* nb_lshift */
     0,                          /* nb_rshift */
@@ -2152,7 +2152,7 @@ PyTypeObject _PyNone_Type = {
     &none_as_number,    /*tp_as_number*/
     0,                  /*tp_as_sequence*/
     0,                  /*tp_as_mapping*/
-    (hashfunc)none_hash,/*tp_hash */
+    none_hash,          /*tp_hash */
     0,                  /*tp_call */
     0,                  /*tp_str */
     0,                  /*tp_getattro */
diff --git a/Objects/rangeobject.c b/Objects/rangeobject.c
index d5cc2b09427dee..24f9ce807fd24e 100644
--- a/Objects/rangeobject.c
+++ b/Objects/rangeobject.c
@@ -733,7 +733,7 @@ range_subscript(PyObject *op, PyObject *item)
 static PyMappingMethods range_as_mapping = {
         range_length,                /* mp_length */
         range_subscript,             /* mp_subscript */
-        (objobjargproc)0,            /* mp_ass_subscript */
+        0,                           /* mp_ass_subscript */
 };
 
 static int
diff --git a/Objects/stringlib/unicode_format.h 
b/Objects/stringlib/unicode_format.h
index 982fc5184a5b2a..ff32db65b11a0b 100644
--- a/Objects/stringlib/unicode_format.h
+++ b/Objects/stringlib/unicode_format.h
@@ -1100,7 +1100,7 @@ static PyTypeObject PyFormatterIter_Type = {
    describing the parsed elements.  It's a wrapper around
    stringlib/string_format.h's MarkupIterator */
 static PyObject *
-formatter_parser(PyObject *ignored, PyObject *self)
+formatter_parser(PyObject *Py_UNUSED(module), PyObject *self)
 {
     formatteriterobject *it;
 
@@ -1236,7 +1236,7 @@ static PyTypeObject PyFieldNameIter_Type = {
    field_name_split.  The iterator it returns is a
    FieldNameIterator */
 static PyObject *
-formatter_field_name_split(PyObject *ignored, PyObject *self)
+formatter_field_name_split(PyObject *Py_UNUSED(module), PyObject *self)
 {
     SubString first;
     Py_ssize_t first_idx;
diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c
index 3e0bd90c17995f..7c735685e89389 100644
--- a/Objects/unicodeobject.c
+++ b/Objects/unicodeobject.c
@@ -14316,7 +14316,7 @@ static PyMethodDef unicode_methods[] = {
     UNICODE_ISPRINTABLE_METHODDEF
     UNICODE_ZFILL_METHODDEF
     {"format", _PyCFunction_CAST(do_string_format), METH_VARARGS | 
METH_KEYWORDS, format__doc__},
-    {"format_map", (PyCFunction) do_string_format_map, METH_O, 
format_map__doc__},
+    {"format_map", do_string_format_map, METH_O, format_map__doc__},
     UNICODE___FORMAT___METHODDEF
     UNICODE_MAKETRANS_METHODDEF
     UNICODE_SIZEOF_METHODDEF
@@ -14340,14 +14340,14 @@ static PyNumberMethods unicode_as_number = {
 };
 
 static PySequenceMethods unicode_as_sequence = {
-    (lenfunc) unicode_length,       /* sq_length */
-    PyUnicode_Concat,           /* sq_concat */
-    (ssizeargfunc) unicode_repeat,  /* sq_repeat */
-    (ssizeargfunc) unicode_getitem,     /* sq_item */
+    unicode_length,     /* sq_length */
+    PyUnicode_Concat,   /* sq_concat */
+    unicode_repeat,     /* sq_repeat */
+    unicode_getitem,    /* sq_item */
     0,                  /* sq_slice */
     0,                  /* sq_ass_item */
     0,                  /* sq_ass_slice */
-    PyUnicode_Contains,         /* sq_contains */
+    PyUnicode_Contains, /* sq_contains */
 };
 
 static PyObject*
@@ -14421,9 +14421,9 @@ unicode_subscript(PyObject* self, PyObject* item)
 }
 
 static PyMappingMethods unicode_as_mapping = {
-    (lenfunc)unicode_length,        /* mp_length */
-    (binaryfunc)unicode_subscript,  /* mp_subscript */
-    (objobjargproc)0,           /* mp_ass_subscript */
+    unicode_length,     /* mp_length */
+    unicode_subscript,  /* mp_subscript */
+    0,                  /* mp_ass_subscript */
 };
 
 
@@ -15566,7 +15566,7 @@ PyTypeObject PyUnicode_Type = {
     sizeof(PyUnicodeObject),      /* tp_basicsize */
     0,                            /* tp_itemsize */
     /* Slots */
-    (destructor)unicode_dealloc,  /* tp_dealloc */
+    unicode_dealloc,              /* tp_dealloc */
     0,                            /* tp_vectorcall_offset */
     0,                            /* tp_getattr */
     0,                            /* tp_setattr */
@@ -15575,9 +15575,9 @@ PyTypeObject PyUnicode_Type = {
     &unicode_as_number,           /* tp_as_number */
     &unicode_as_sequence,         /* tp_as_sequence */
     &unicode_as_mapping,          /* tp_as_mapping */
-    (hashfunc) unicode_hash,      /* tp_hash*/
+    unicode_hash,                 /* tp_hash*/
     0,                            /* tp_call*/
-    (reprfunc) unicode_str,       /* tp_str */
+    unicode_str,                  /* tp_str */
     PyObject_GenericGetAttr,      /* tp_getattro */
     0,                            /* tp_setattro */
     0,                            /* tp_as_buffer */
@@ -16474,9 +16474,9 @@ _PyUnicode_Fini(PyInterpreterState *interp)
    to the string.Formatter class implemented in Python. */
 
 static PyMethodDef _string_methods[] = {
-    {"formatter_field_name_split", (PyCFunction) formatter_field_name_split,
+    {"formatter_field_name_split", formatter_field_name_split,
      METH_O, PyDoc_STR("split the argument as a field name")},
-    {"formatter_parser", (PyCFunction) formatter_parser,
+    {"formatter_parser", formatter_parser,
      METH_O, PyDoc_STR("parse the argument as a format string")},
     {NULL, NULL}
 };
diff --git a/Objects/unionobject.c b/Objects/unionobject.c
index 08422662e8118a..0b7d4c72bffb97 100644
--- a/Objects/unionobject.c
+++ b/Objects/unionobject.c
@@ -380,7 +380,7 @@ static PyGetSetDef union_properties[] = {
      PyDoc_STR("Qualified name of the type"), NULL},
     {"__origin__", union_origin, NULL,
      PyDoc_STR("Always returns the type"), NULL},
-    {"__parameters__", union_parameters, (setter)NULL,
+    {"__parameters__", union_parameters, NULL,
      PyDoc_STR("Type variables in the types.UnionType."), NULL},
     {0}
 };
diff --git a/Python/hamt.c b/Python/hamt.c
index 42a0baffd9def9..e4d1e1663dd573 100644
--- a/Python/hamt.c
+++ b/Python/hamt.c
@@ -2516,7 +2516,7 @@ hamt_baseiter_new(PyTypeObject *type, binaryfunc yield, 
PyHamtObject *o)
     .tp_traverse = hamt_baseiter_tp_traverse,                   \
     .tp_clear = hamt_baseiter_tp_clear,                         \
     .tp_iter = PyObject_SelfIter,                               \
-    .tp_iternext = (iternextfunc)hamt_baseiter_tp_iternext,
+    .tp_iternext = hamt_baseiter_tp_iternext,
 
 
 /////////////////////////////////// _PyHamtItems_Type

_______________________________________________
Python-checkins mailing list -- python-checkins@python.org
To unsubscribe send an email to python-checkins-le...@python.org
https://mail.python.org/mailman3/lists/python-checkins.python.org/
Member address: arch...@mail-archive.com

Reply via email to