Skip to content

Commit 70861ec

Browse files
committed
remove un-necessary casts to PyCFunction
1 parent af29d5c commit 70861ec

File tree

14 files changed

+61
-64
lines changed

14 files changed

+61
-64
lines changed

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
@@ -1636,19 +1636,19 @@ _functools__lru_cache_wrapper_cache_clear_impl(PyObject *self)
16361636
}
16371637

16381638
static PyObject *
1639-
lru_cache_reduce(PyObject *self, PyObject *unused)
1639+
lru_cache_reduce(PyObject *self, PyObject *Py_UNUSED(ignored))
16401640
{
16411641
return PyObject_GetAttrString(self, "__qualname__");
16421642
}
16431643

16441644
static PyObject *
1645-
lru_cache_copy(PyObject *self, PyObject *unused)
1645+
lru_cache_copy(PyObject *self, PyObject *Py_UNUSED(args))
16461646
{
16471647
return Py_NewRef(self);
16481648
}
16491649

16501650
static PyObject *
1651-
lru_cache_deepcopy(PyObject *self, PyObject *unused)
1651+
lru_cache_deepcopy(PyObject *self, PyObject *Py_UNUSED(args))
16521652
{
16531653
return Py_NewRef(self);
16541654
}
@@ -1695,9 +1695,9 @@ cache_info_type: namedtuple class with the fields:\n\
16951695
static PyMethodDef lru_cache_methods[] = {
16961696
_FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_INFO_METHODDEF
16971697
_FUNCTOOLS__LRU_CACHE_WRAPPER_CACHE_CLEAR_METHODDEF
1698-
{"__reduce__", (PyCFunction)lru_cache_reduce, METH_NOARGS},
1699-
{"__copy__", (PyCFunction)lru_cache_copy, METH_VARARGS},
1700-
{"__deepcopy__", (PyCFunction)lru_cache_deepcopy, METH_VARARGS},
1698+
{"__reduce__", lru_cache_reduce, METH_NOARGS},
1699+
{"__copy__", lru_cache_copy, METH_VARARGS},
1700+
{"__deepcopy__", lru_cache_deepcopy, METH_VARARGS},
17011701
{NULL}
17021702
};
17031703

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/mem.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@ static PyMethodDef test_methods[] = {
691691
{"pyobject_malloc_without_gil", pyobject_malloc_without_gil, METH_NOARGS},
692692
{"remove_mem_hooks", remove_mem_hooks, METH_NOARGS,
693693
PyDoc_STR("Remove memory hooks.")},
694-
{"set_nomemory", (PyCFunction)set_nomemory, METH_VARARGS,
694+
{"set_nomemory", set_nomemory, METH_VARARGS,
695695
PyDoc_STR("set_nomemory(start:int, stop:int = 0)")},
696696
{"test_pymem_alloc0", test_pymem_alloc0, METH_NOARGS},
697697
{"test_pymem_setallocators", test_pymem_setallocators, METH_NOARGS},

Modules/_testcapi/watchers.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ _testcapi_unwatch_dict_impl(PyObject *module, int watcher_id, PyObject *dict)
162162
}
163163

164164
static PyObject *
165-
get_dict_watcher_events(PyObject *self, PyObject *Py_UNUSED(args))
165+
get_dict_watcher_events(PyObject *self, PyObject *Py_UNUSED(ignored))
166166
{
167167
if (!g_dict_watch_events) {
168168
PyErr_SetString(PyExc_RuntimeError, "no watchers active");
@@ -255,7 +255,7 @@ clear_type_watcher(PyObject *self, PyObject *watcher_id)
255255
}
256256

257257
static PyObject *
258-
get_type_modified_events(PyObject *self, PyObject *Py_UNUSED(args))
258+
get_type_modified_events(PyObject *self, PyObject *Py_UNUSED(ignored))
259259
{
260260
if (!g_type_modified_events) {
261261
PyErr_SetString(PyExc_RuntimeError, "no watchers active");
@@ -413,7 +413,7 @@ get_code_watcher_num_destroyed_events(PyObject *self, PyObject *watcher_id)
413413
}
414414

415415
static PyObject *
416-
allocate_too_many_code_watchers(PyObject *self, PyObject *args)
416+
allocate_too_many_code_watchers(PyObject *self, PyObject *Py_UNUSED(ignored))
417417
{
418418
int watcher_ids[CODE_MAX_WATCHERS + 1];
419419
int num_watchers = 0;
@@ -742,7 +742,7 @@ get_context_switches(PyObject *Py_UNUSED(self), PyObject *watcher_id)
742742
}
743743

744744
static PyObject *
745-
allocate_too_many_context_watchers(PyObject *self, PyObject *args)
745+
allocate_too_many_context_watchers(PyObject *self, PyObject *Py_UNUSED(ignored))
746746
{
747747
int watcher_ids[CONTEXT_MAX_WATCHERS + 1];
748748
int num_watchers = 0;
@@ -811,16 +811,15 @@ static PyMethodDef test_methods[] = {
811811
{"clear_dict_watcher", clear_dict_watcher, METH_O, NULL},
812812
_TESTCAPI_WATCH_DICT_METHODDEF
813813
_TESTCAPI_UNWATCH_DICT_METHODDEF
814-
{"get_dict_watcher_events",
815-
(PyCFunction) get_dict_watcher_events, METH_NOARGS, NULL},
814+
{"get_dict_watcher_events", get_dict_watcher_events, METH_NOARGS, NULL},
816815

817816
// Type watchers.
818817
{"add_type_watcher", add_type_watcher, METH_O, NULL},
819818
{"clear_type_watcher", clear_type_watcher, METH_O, NULL},
820819
_TESTCAPI_WATCH_TYPE_METHODDEF
821820
_TESTCAPI_UNWATCH_TYPE_METHODDEF
822821
{"get_type_modified_events",
823-
(PyCFunction) get_type_modified_events, METH_NOARGS, NULL},
822+
get_type_modified_events, METH_NOARGS, NULL},
824823

825824
// Code object watchers.
826825
{"add_code_watcher", add_code_watcher, METH_O, NULL},
@@ -830,7 +829,7 @@ static PyMethodDef test_methods[] = {
830829
{"get_code_watcher_num_destroyed_events",
831830
get_code_watcher_num_destroyed_events, METH_O, NULL},
832831
{"allocate_too_many_code_watchers",
833-
(PyCFunction) allocate_too_many_code_watchers, METH_NOARGS, NULL},
832+
allocate_too_many_code_watchers, METH_NOARGS, NULL},
834833

835834
// Function watchers.
836835
{"add_func_watcher", add_func_watcher, METH_O, NULL},
@@ -846,7 +845,7 @@ static PyMethodDef test_methods[] = {
846845
{"clear_context_stack", clear_context_stack, METH_NOARGS, NULL},
847846
{"get_context_switches", get_context_switches, METH_O, NULL},
848847
{"allocate_too_many_context_watchers",
849-
(PyCFunction) allocate_too_many_context_watchers, METH_NOARGS, NULL},
848+
allocate_too_many_context_watchers, METH_NOARGS, NULL},
850849
{NULL},
851850
};
852851

Modules/_xxtestfuzz/_xxtestfuzz.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ static PyObject* _fuzz_run(PyObject* self, PyObject* args) {
2424
}
2525

2626
static PyMethodDef module_methods[] = {
27-
{"run", (PyCFunction)_fuzz_run, METH_VARARGS, ""},
27+
{"run", _fuzz_run, METH_VARARGS, ""},
2828
{NULL},
2929
};
3030

Modules/_zoneinfo.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2605,13 +2605,13 @@ static PyMethodDef zoneinfo_methods[] = {
26052605
ZONEINFO_ZONEINFO_UTCOFFSET_METHODDEF
26062606
ZONEINFO_ZONEINFO_DST_METHODDEF
26072607
ZONEINFO_ZONEINFO_TZNAME_METHODDEF
2608-
{"fromutc", (PyCFunction)zoneinfo_fromutc, METH_O,
2608+
{"fromutc", zoneinfo_fromutc, METH_O,
26092609
PyDoc_STR("Given a datetime with local time in UTC, retrieve an adjusted "
26102610
"datetime in local time.")},
2611-
{"__reduce__", (PyCFunction)zoneinfo_reduce, METH_NOARGS,
2611+
{"__reduce__", zoneinfo_reduce, METH_NOARGS,
26122612
PyDoc_STR("Function for serialization with the pickle protocol.")},
26132613
ZONEINFO_ZONEINFO__UNPICKLE_METHODDEF
2614-
{"__init_subclass__", (PyCFunction)(void (*)(void))zoneinfo_init_subclass,
2614+
{"__init_subclass__", _PyCFunction_CAST(zoneinfo_init_subclass),
26152615
METH_VARARGS | METH_KEYWORDS | METH_CLASS,
26162616
PyDoc_STR("Function to initialize subclasses.")},
26172617
{NULL} /* Sentinel */

Modules/atexitmodule.c

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@ Run all registered exit functions.\n\
217217
If a callback raises an exception, it is logged with sys.unraisablehook.");
218218

219219
static PyObject *
220-
atexit_run_exitfuncs(PyObject *module, PyObject *unused)
220+
atexit_run_exitfuncs(PyObject *module, PyObject *Py_UNUSED(ignored))
221221
{
222222
struct atexit_state *state = get_atexit_state();
223223
atexit_callfuncs(state);
@@ -231,7 +231,7 @@ PyDoc_STRVAR(atexit_clear__doc__,
231231
Clear the list of previously registered exit functions.");
232232

233233
static PyObject *
234-
atexit_clear(PyObject *module, PyObject *unused)
234+
atexit_clear(PyObject *module, PyObject *Py_UNUSED(ignored))
235235
{
236236
atexit_cleanup(get_atexit_state());
237237
Py_RETURN_NONE;
@@ -244,7 +244,7 @@ PyDoc_STRVAR(atexit_ncallbacks__doc__,
244244
Return the number of registered exit functions.");
245245

246246
static PyObject *
247-
atexit_ncallbacks(PyObject *module, PyObject *unused)
247+
atexit_ncallbacks(PyObject *module, PyObject *Py_UNUSED(ignored))
248248
{
249249
struct atexit_state *state = get_atexit_state();
250250
assert(state->callbacks != NULL);
@@ -300,13 +300,11 @@ atexit_unregister(PyObject *module, PyObject *func)
300300
static PyMethodDef atexit_methods[] = {
301301
{"register", _PyCFunction_CAST(atexit_register), METH_VARARGS|METH_KEYWORDS,
302302
atexit_register__doc__},
303-
{"_clear", (PyCFunction) atexit_clear, METH_NOARGS,
304-
atexit_clear__doc__},
305-
{"unregister", (PyCFunction) atexit_unregister, METH_O,
306-
atexit_unregister__doc__},
307-
{"_run_exitfuncs", (PyCFunction) atexit_run_exitfuncs, METH_NOARGS,
303+
{"_clear", atexit_clear, METH_NOARGS, atexit_clear__doc__},
304+
{"unregister", atexit_unregister, METH_O, atexit_unregister__doc__},
305+
{"_run_exitfuncs", atexit_run_exitfuncs, METH_NOARGS,
308306
atexit_run_exitfuncs__doc__},
309-
{"_ncallbacks", (PyCFunction) atexit_ncallbacks, METH_NOARGS,
307+
{"_ncallbacks", atexit_ncallbacks, METH_NOARGS,
310308
atexit_ncallbacks__doc__},
311309
{NULL, NULL} /* sentinel */
312310
};

0 commit comments

Comments
 (0)