Skip to content

Commit edbf7fb

Browse files
authored
gh-111178: remove redundant casts for functions with correct signatures (#131673)
1 parent 8cd29c2 commit edbf7fb

30 files changed

+96
-101
lines changed

Modules/_asynciomodule.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,7 +2956,7 @@ static PyType_Slot Task_slots[] = {
29562956
{Py_tp_iter, future_new_iter},
29572957
{Py_tp_methods, TaskType_methods},
29582958
{Py_tp_getset, TaskType_getsetlist},
2959-
{Py_tp_init, (initproc)_asyncio_Task___init__},
2959+
{Py_tp_init, _asyncio_Task___init__},
29602960
{Py_tp_new, PyType_GenericNew},
29612961
{Py_tp_finalize, TaskObj_finalize},
29622962

@@ -4396,7 +4396,7 @@ static struct PyModuleDef _asynciomodule = {
43964396
.m_slots = module_slots,
43974397
.m_traverse = module_traverse,
43984398
.m_clear = module_clear,
4399-
.m_free = (freefunc)module_free,
4399+
.m_free = module_free,
44004400
};
44014401

44024402
PyMODINIT_FUNC

Modules/_cursesmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2709,7 +2709,7 @@ static PyMethodDef PyCursesWindow_methods[] = {
27092709
_CURSES_WINDOW_SETSCRREG_METHODDEF
27102710
{"standend", PyCursesWindow_wstandend, METH_NOARGS},
27112711
{"standout", PyCursesWindow_wstandout, METH_NOARGS},
2712-
{"subpad", (PyCFunction)_curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__},
2712+
{"subpad", _curses_window_subwin, METH_VARARGS, _curses_window_subwin__doc__},
27132713
_CURSES_WINDOW_SUBWIN_METHODDEF
27142714
{"syncdown", PyCursesWindow_wsyncdown, METH_NOARGS},
27152715
#ifdef HAVE_CURSES_SYNCOK

Modules/_functoolsmodule.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,19 +1634,19 @@ _functools__lru_cache_wrapper_cache_clear_impl(PyObject *self)
16341634
}
16351635

16361636
static PyObject *
1637-
lru_cache_reduce(PyObject *self, PyObject *unused)
1637+
lru_cache_reduce(PyObject *self, PyObject *Py_UNUSED(dummy))
16381638
{
16391639
return PyObject_GetAttrString(self, "__qualname__");
16401640
}
16411641

16421642
static PyObject *
1643-
lru_cache_copy(PyObject *self, PyObject *unused)
1643+
lru_cache_copy(PyObject *self, PyObject *Py_UNUSED(args))
16441644
{
16451645
return Py_NewRef(self);
16461646
}
16471647

16481648
static PyObject *
1649-
lru_cache_deepcopy(PyObject *self, PyObject *unused)
1649+
lru_cache_deepcopy(PyObject *self, PyObject *Py_UNUSED(args))
16501650
{
16511651
return Py_NewRef(self);
16521652
}
@@ -1693,9 +1693,9 @@ cache_info_type: namedtuple class with the fields:\n\
16931693
static PyMethodDef lru_cache_methods[] = {
16941694
_FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_INFO_METHODDEF
16951695
_FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_CLEAR_METHODDEF
1696-
{"__reduce__", (PyCFunction)lru_cache_reduce, METH_NOARGS},
1697-
{"__copy__", (PyCFunction)lru_cache_copy, METH_VARARGS},
1698-
{"__deepcopy__", (PyCFunction)lru_cache_deepcopy, METH_VARARGS},
1696+
{"__reduce__", lru_cache_reduce, METH_NOARGS},
1697+
{"__copy__", lru_cache_copy, METH_VARARGS},
1698+
{"__deepcopy__", lru_cache_deepcopy, METH_VARARGS},
16991699
{NULL}
17001700
};
17011701

Modules/_interpchannelsmodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3595,7 +3595,7 @@ static struct PyModuleDef moduledef = {
35953595
.m_slots = module_slots,
35963596
.m_traverse = module_traverse,
35973597
.m_clear = module_clear,
3598-
.m_free = (freefunc)module_free,
3598+
.m_free = module_free,
35993599
};
36003600

36013601
PyMODINIT_FUNC

Modules/_io/textio.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3386,8 +3386,6 @@ static PyMemberDef textiowrapper_members[] = {
33863386
static PyGetSetDef textiowrapper_getset[] = {
33873387
_IO_TEXTIOWRAPPER_NAME_GETSETDEF
33883388
_IO_TEXTIOWRAPPER_CLOSED_GETSETDEF
3389-
/* {"mode", (getter)TextIOWrapper_mode_get, NULL, NULL},
3390-
*/
33913389
_IO_TEXTIOWRAPPER_NEWLINES_GETSETDEF
33923390
_IO_TEXTIOWRAPPER_ERRORS_GETSETDEF
33933391
_IO_TEXTIOWRAPPER__CHUNK_SIZE_GETSETDEF

Modules/_io/winconsoleio.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1195,7 +1195,7 @@ static PyMethodDef winconsoleio_methods[] = {
11951195
_IO__WINDOWSCONSOLEIO_WRITABLE_METHODDEF
11961196
_IO__WINDOWSCONSOLEIO_FILENO_METHODDEF
11971197
_IO__WINDOWSCONSOLEIO_ISATTY_METHODDEF
1198-
{"_isatty_open_only", (PyCFunction)_io__WindowsConsoleIO_isatty, METH_NOARGS},
1198+
{"_isatty_open_only", _io__WindowsConsoleIO_isatty, METH_NOARGS},
11991199
{NULL, NULL} /* sentinel */
12001200
};
12011201

Modules/_lzmamodule.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1410,7 +1410,7 @@ PyDoc_STRVAR(_lzma__encode_filter_properties__doc__,
14101410
"The result does not include the filter ID itself, only the options.");
14111411

14121412
#define _LZMA__ENCODE_FILTER_PROPERTIES_METHODDEF \
1413-
{"_encode_filter_properties", (PyCFunction)_lzma__encode_filter_properties, METH_O, _lzma__encode_filter_properties__doc__},
1413+
{"_encode_filter_properties", _lzma__encode_filter_properties, METH_O, _lzma__encode_filter_properties__doc__},
14141414

14151415
static PyObject *
14161416
_lzma__encode_filter_properties_impl(PyObject *module, lzma_filter filter);

Modules/_testcapi/docstring.c

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,42 +66,42 @@ test_with_docstring(PyObject *self, PyObject *Py_UNUSED(ignored))
6666

6767
static PyMethodDef test_methods[] = {
6868
{"docstring_empty",
69-
(PyCFunction)test_with_docstring, METH_VARARGS,
69+
test_with_docstring, METH_VARARGS,
7070
docstring_empty},
7171
{"docstring_no_signature",
72-
(PyCFunction)test_with_docstring, METH_VARARGS,
72+
test_with_docstring, METH_VARARGS,
7373
docstring_no_signature},
7474
{"docstring_no_signature_noargs",
75-
(PyCFunction)test_with_docstring, METH_NOARGS,
75+
test_with_docstring, METH_NOARGS,
7676
docstring_no_signature},
7777
{"docstring_no_signature_o",
78-
(PyCFunction)test_with_docstring, METH_O,
78+
test_with_docstring, METH_O,
7979
docstring_no_signature},
8080
{"docstring_with_invalid_signature",
81-
(PyCFunction)test_with_docstring, METH_VARARGS,
81+
test_with_docstring, METH_VARARGS,
8282
docstring_with_invalid_signature},
8383
{"docstring_with_invalid_signature2",
84-
(PyCFunction)test_with_docstring, METH_VARARGS,
84+
test_with_docstring, METH_VARARGS,
8585
docstring_with_invalid_signature2},
8686
{"docstring_with_signature",
87-
(PyCFunction)test_with_docstring, METH_VARARGS,
87+
test_with_docstring, METH_VARARGS,
8888
docstring_with_signature},
8989
{"docstring_with_signature_and_extra_newlines",
90-
(PyCFunction)test_with_docstring, METH_VARARGS,
90+
test_with_docstring, METH_VARARGS,
9191
docstring_with_signature_and_extra_newlines},
9292
{"docstring_with_signature_but_no_doc",
93-
(PyCFunction)test_with_docstring, METH_VARARGS,
93+
test_with_docstring, METH_VARARGS,
9494
docstring_with_signature_but_no_doc},
9595
{"docstring_with_signature_with_defaults",
96-
(PyCFunction)test_with_docstring, METH_VARARGS,
96+
test_with_docstring, METH_VARARGS,
9797
docstring_with_signature_with_defaults},
9898
{"no_docstring",
99-
(PyCFunction)test_with_docstring, METH_VARARGS},
99+
test_with_docstring, METH_VARARGS},
100100
{"test_with_docstring",
101101
test_with_docstring, METH_VARARGS,
102102
PyDoc_STR("This is a pretty normal docstring.")},
103103
{"func_with_unrepresentable_signature",
104-
(PyCFunction)test_with_docstring, METH_VARARGS,
104+
test_with_docstring, METH_VARARGS,
105105
PyDoc_STR(
106106
"func_with_unrepresentable_signature($module, /, a, b=<x>)\n"
107107
"--\n\n"
@@ -112,28 +112,28 @@ static PyMethodDef test_methods[] = {
112112

113113
static PyMethodDef DocStringNoSignatureTest_methods[] = {
114114
{"meth_noargs",
115-
(PyCFunction)test_with_docstring, METH_NOARGS,
115+
test_with_docstring, METH_NOARGS,
116116
docstring_no_signature},
117117
{"meth_o",
118-
(PyCFunction)test_with_docstring, METH_O,
118+
test_with_docstring, METH_O,
119119
docstring_no_signature},
120120
{"meth_noargs_class",
121-
(PyCFunction)test_with_docstring, METH_NOARGS|METH_CLASS,
121+
test_with_docstring, METH_NOARGS|METH_CLASS,
122122
docstring_no_signature},
123123
{"meth_o_class",
124-
(PyCFunction)test_with_docstring, METH_O|METH_CLASS,
124+
test_with_docstring, METH_O|METH_CLASS,
125125
docstring_no_signature},
126126
{"meth_noargs_static",
127-
(PyCFunction)test_with_docstring, METH_NOARGS|METH_STATIC,
127+
test_with_docstring, METH_NOARGS|METH_STATIC,
128128
docstring_no_signature},
129129
{"meth_o_static",
130-
(PyCFunction)test_with_docstring, METH_O|METH_STATIC,
130+
test_with_docstring, METH_O|METH_STATIC,
131131
docstring_no_signature},
132132
{"meth_noargs_coexist",
133-
(PyCFunction)test_with_docstring, METH_NOARGS|METH_COEXIST,
133+
test_with_docstring, METH_NOARGS|METH_COEXIST,
134134
docstring_no_signature},
135135
{"meth_o_coexist",
136-
(PyCFunction)test_with_docstring, METH_O|METH_COEXIST,
136+
test_with_docstring, METH_O|METH_COEXIST,
137137
docstring_no_signature},
138138
{NULL},
139139
};
@@ -149,28 +149,28 @@ static PyTypeObject DocStringNoSignatureTest = {
149149

150150
static PyMethodDef DocStringUnrepresentableSignatureTest_methods[] = {
151151
{"meth",
152-
(PyCFunction)test_with_docstring, METH_VARARGS,
152+
test_with_docstring, METH_VARARGS,
153153
PyDoc_STR(
154154
"meth($self, /, a, b=<x>)\n"
155155
"--\n\n"
156156
"This docstring has a signature with unrepresentable default."
157157
)},
158158
{"classmeth",
159-
(PyCFunction)test_with_docstring, METH_VARARGS|METH_CLASS,
159+
test_with_docstring, METH_VARARGS|METH_CLASS,
160160
PyDoc_STR(
161161
"classmeth($type, /, a, b=<x>)\n"
162162
"--\n\n"
163163
"This docstring has a signature with unrepresentable default."
164164
)},
165165
{"staticmeth",
166-
(PyCFunction)test_with_docstring, METH_VARARGS|METH_STATIC,
166+
test_with_docstring, METH_VARARGS|METH_STATIC,
167167
PyDoc_STR(
168168
"staticmeth(a, b=<x>)\n"
169169
"--\n\n"
170170
"This docstring has a signature with unrepresentable default."
171171
)},
172172
{"with_default",
173-
(PyCFunction)test_with_docstring, METH_VARARGS,
173+
test_with_docstring, METH_VARARGS,
174174
PyDoc_STR(
175175
"with_default($self, /, x=ONE)\n"
176176
"--\n\n"

Modules/_testcapi/exceptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ static PyTypeObject PyRecursingInfinitelyError_Type = {
538538
.tp_basicsize = sizeof(PyBaseExceptionObject),
539539
.tp_flags = Py_TPFLAGS_DEFAULT | Py_TPFLAGS_BASETYPE,
540540
.tp_doc = PyDoc_STR("Instantiating this exception starts infinite recursion."),
541-
.tp_init = (initproc)recurse_infinitely_error_init,
541+
.tp_init = recurse_infinitely_error_init,
542542
};
543543

544544
static PyMethodDef test_methods[] = {

Modules/_testcapi/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ obj_extra_data_set(PyObject *self, PyObject *newval, void *Py_UNUSED(ignored))
265265
}
266266

267267
static PyGetSetDef obj_extra_data_getset[] = {
268-
{"extra", (getter)obj_extra_data_get, (setter)obj_extra_data_set, NULL},
268+
{"extra", obj_extra_data_get, obj_extra_data_set, NULL},
269269
{NULL}
270270
};
271271

0 commit comments

Comments
 (0)