Skip to content

Commit 804f252

Browse files
authored
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")
1 parent 551d02b commit 804f252

31 files changed

+146
-146
lines changed

Modules/_asynciomodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1724,7 +1724,7 @@ FutureIter_traverse(futureiterobject *it, visitproc visit, void *arg)
17241724

17251725
static PyMethodDef FutureIter_methods[] = {
17261726
{"send", (PyCFunction)FutureIter_send, METH_O, NULL},
1727-
{"throw", (PyCFunction)(void(*)(void))FutureIter_throw, METH_FASTCALL, NULL},
1727+
{"throw", _PyCFunction_CAST(FutureIter_throw), METH_FASTCALL, NULL},
17281728
{"close", (PyCFunction)FutureIter_close, METH_NOARGS, NULL},
17291729
{NULL, NULL} /* Sentinel */
17301730
};

Modules/_collectionsmodule.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1588,9 +1588,9 @@ static PyMethodDef deque_methods[] = {
15881588
METH_O, extend_doc},
15891589
{"extendleft", (PyCFunction)deque_extendleft,
15901590
METH_O, extendleft_doc},
1591-
{"index", (PyCFunction)(void(*)(void))deque_index,
1591+
{"index", _PyCFunction_CAST(deque_index),
15921592
METH_FASTCALL, index_doc},
1593-
{"insert", (PyCFunction)(void(*)(void))deque_insert,
1593+
{"insert", _PyCFunction_CAST(deque_insert),
15941594
METH_FASTCALL, insert_doc},
15951595
{"pop", (PyCFunction)deque_pop,
15961596
METH_NOARGS, pop_doc},
@@ -1604,7 +1604,7 @@ static PyMethodDef deque_methods[] = {
16041604
METH_NOARGS, reversed_doc},
16051605
{"reverse", (PyCFunction)deque_reverse,
16061606
METH_NOARGS, reverse_doc},
1607-
{"rotate", (PyCFunction)(void(*)(void))deque_rotate,
1607+
{"rotate", _PyCFunction_CAST(deque_rotate),
16081608
METH_FASTCALL, rotate_doc},
16091609
{"__sizeof__", (PyCFunction)deque_sizeof,
16101610
METH_NOARGS, sizeof_doc},

Modules/_csv.c

+3-3
Original file line numberDiff line numberDiff line change
@@ -1704,11 +1704,11 @@ PyDoc_STRVAR(csv_register_dialect_doc,
17041704
" dialect = csv.register_dialect(name[, dialect[, **fmtparams]])");
17051705

17061706
static struct PyMethodDef csv_methods[] = {
1707-
{ "reader", (PyCFunction)(void(*)(void))csv_reader,
1707+
{ "reader", _PyCFunction_CAST(csv_reader),
17081708
METH_VARARGS | METH_KEYWORDS, csv_reader_doc},
1709-
{ "writer", (PyCFunction)(void(*)(void))csv_writer,
1709+
{ "writer", _PyCFunction_CAST(csv_writer),
17101710
METH_VARARGS | METH_KEYWORDS, csv_writer_doc},
1711-
{ "register_dialect", (PyCFunction)(void(*)(void))csv_register_dialect,
1711+
{ "register_dialect", _PyCFunction_CAST(csv_register_dialect),
17121712
METH_VARARGS | METH_KEYWORDS, csv_register_dialect_doc},
17131713
_CSV_LIST_DIALECTS_METHODDEF
17141714
_CSV_UNREGISTER_DIALECT_METHODDEF

Modules/_datetimemodule.c

+11-11
Original file line numberDiff line numberDiff line change
@@ -3491,7 +3491,7 @@ static PyMethodDef date_methods[] = {
34913491
METH_CLASS,
34923492
PyDoc_STR("str -> Construct a date from the output of date.isoformat()")},
34933493

3494-
{"fromisocalendar", (PyCFunction)(void(*)(void))date_fromisocalendar,
3494+
{"fromisocalendar", _PyCFunction_CAST(date_fromisocalendar),
34953495
METH_VARARGS | METH_KEYWORDS | METH_CLASS,
34963496
PyDoc_STR("int, int, int -> Construct a date from the ISO year, week "
34973497
"number and weekday.\n\n"
@@ -3506,7 +3506,7 @@ static PyMethodDef date_methods[] = {
35063506
{"ctime", (PyCFunction)date_ctime, METH_NOARGS,
35073507
PyDoc_STR("Return ctime() style string.")},
35083508

3509-
{"strftime", (PyCFunction)(void(*)(void))date_strftime, METH_VARARGS | METH_KEYWORDS,
3509+
{"strftime", _PyCFunction_CAST(date_strftime), METH_VARARGS | METH_KEYWORDS,
35103510
PyDoc_STR("format -> strftime() style string.")},
35113511

35123512
{"__format__", (PyCFunction)date_format, METH_VARARGS,
@@ -3534,7 +3534,7 @@ static PyMethodDef date_methods[] = {
35343534
PyDoc_STR("Return the day of the week represented by the date.\n"
35353535
"Monday == 0 ... Sunday == 6")},
35363536

3537-
{"replace", (PyCFunction)(void(*)(void))date_replace, METH_VARARGS | METH_KEYWORDS,
3537+
{"replace", _PyCFunction_CAST(date_replace), METH_VARARGS | METH_KEYWORDS,
35383538
PyDoc_STR("Return date with new specified fields.")},
35393539

35403540
{"__reduce__", (PyCFunction)date_reduce, METH_NOARGS,
@@ -4644,15 +4644,15 @@ time_reduce(PyDateTime_Time *self, PyObject *arg)
46444644

46454645
static PyMethodDef time_methods[] = {
46464646

4647-
{"isoformat", (PyCFunction)(void(*)(void))time_isoformat, METH_VARARGS | METH_KEYWORDS,
4647+
{"isoformat", _PyCFunction_CAST(time_isoformat), METH_VARARGS | METH_KEYWORDS,
46484648
PyDoc_STR("Return string in ISO 8601 format, [HH[:MM[:SS[.mmm[uuu]]]]]"
46494649
"[+HH:MM].\n\n"
46504650
"The optional argument timespec specifies the number "
46514651
"of additional terms\nof the time to include. Valid "
46524652
"options are 'auto', 'hours', 'minutes',\n'seconds', "
46534653
"'milliseconds' and 'microseconds'.\n")},
46544654

4655-
{"strftime", (PyCFunction)(void(*)(void))time_strftime, METH_VARARGS | METH_KEYWORDS,
4655+
{"strftime", _PyCFunction_CAST(time_strftime), METH_VARARGS | METH_KEYWORDS,
46564656
PyDoc_STR("format -> strftime() style string.")},
46574657

46584658
{"__format__", (PyCFunction)date_format, METH_VARARGS,
@@ -4667,7 +4667,7 @@ static PyMethodDef time_methods[] = {
46674667
{"dst", (PyCFunction)time_dst, METH_NOARGS,
46684668
PyDoc_STR("Return self.tzinfo.dst(self).")},
46694669

4670-
{"replace", (PyCFunction)(void(*)(void))time_replace, METH_VARARGS | METH_KEYWORDS,
4670+
{"replace", _PyCFunction_CAST(time_replace), METH_VARARGS | METH_KEYWORDS,
46714671
PyDoc_STR("Return time with new specified fields.")},
46724672

46734673
{"fromisoformat", (PyCFunction)time_fromisoformat, METH_O | METH_CLASS,
@@ -6308,7 +6308,7 @@ static PyMethodDef datetime_methods[] = {
63086308
METH_NOARGS | METH_CLASS,
63096309
PyDoc_STR("Return a new datetime representing UTC day and time.")},
63106310

6311-
{"fromtimestamp", (PyCFunction)(void(*)(void))datetime_fromtimestamp,
6311+
{"fromtimestamp", _PyCFunction_CAST(datetime_fromtimestamp),
63126312
METH_VARARGS | METH_KEYWORDS | METH_CLASS,
63136313
PyDoc_STR("timestamp[, tz] -> tz's local time from POSIX timestamp.")},
63146314

@@ -6321,7 +6321,7 @@ static PyMethodDef datetime_methods[] = {
63216321
PyDoc_STR("string, format -> new datetime parsed from a string "
63226322
"(like time.strptime()).")},
63236323

6324-
{"combine", (PyCFunction)(void(*)(void))datetime_combine,
6324+
{"combine", _PyCFunction_CAST(datetime_combine),
63256325
METH_VARARGS | METH_KEYWORDS | METH_CLASS,
63266326
PyDoc_STR("date, time -> datetime with same date and time fields")},
63276327

@@ -6352,7 +6352,7 @@ static PyMethodDef datetime_methods[] = {
63526352
{"utctimetuple", (PyCFunction)datetime_utctimetuple, METH_NOARGS,
63536353
PyDoc_STR("Return UTC time tuple, compatible with time.localtime().")},
63546354

6355-
{"isoformat", (PyCFunction)(void(*)(void))datetime_isoformat, METH_VARARGS | METH_KEYWORDS,
6355+
{"isoformat", _PyCFunction_CAST(datetime_isoformat), METH_VARARGS | METH_KEYWORDS,
63566356
PyDoc_STR("[sep] -> string in ISO 8601 format, "
63576357
"YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].\n"
63586358
"sep is used to separate the year from the time, and "
@@ -6371,10 +6371,10 @@ static PyMethodDef datetime_methods[] = {
63716371
{"dst", (PyCFunction)datetime_dst, METH_NOARGS,
63726372
PyDoc_STR("Return self.tzinfo.dst(self).")},
63736373

6374-
{"replace", (PyCFunction)(void(*)(void))datetime_replace, METH_VARARGS | METH_KEYWORDS,
6374+
{"replace", _PyCFunction_CAST(datetime_replace), METH_VARARGS | METH_KEYWORDS,
63756375
PyDoc_STR("Return datetime with new specified fields.")},
63766376

6377-
{"astimezone", (PyCFunction)(void(*)(void))datetime_astimezone, METH_VARARGS | METH_KEYWORDS,
6377+
{"astimezone", _PyCFunction_CAST(datetime_astimezone), METH_VARARGS | METH_KEYWORDS,
63786378
PyDoc_STR("tz -> convert to local time in new timezone tz\n")},
63796379

63806380
{"__reduce_ex__", (PyCFunction)datetime_reduce_ex, METH_VARARGS,

Modules/_decimal/_decimal.c

+38-38
Original file line numberDiff line numberDiff line change
@@ -4904,30 +4904,30 @@ static PyNumberMethods dec_number_methods =
49044904
static PyMethodDef dec_methods [] =
49054905
{
49064906
/* Unary arithmetic functions, optional context arg */
4907-
{ "exp", (PyCFunction)(void(*)(void))dec_mpd_qexp, METH_VARARGS|METH_KEYWORDS, doc_exp },
4908-
{ "ln", (PyCFunction)(void(*)(void))dec_mpd_qln, METH_VARARGS|METH_KEYWORDS, doc_ln },
4909-
{ "log10", (PyCFunction)(void(*)(void))dec_mpd_qlog10, METH_VARARGS|METH_KEYWORDS, doc_log10 },
4910-
{ "next_minus", (PyCFunction)(void(*)(void))dec_mpd_qnext_minus, METH_VARARGS|METH_KEYWORDS, doc_next_minus },
4911-
{ "next_plus", (PyCFunction)(void(*)(void))dec_mpd_qnext_plus, METH_VARARGS|METH_KEYWORDS, doc_next_plus },
4912-
{ "normalize", (PyCFunction)(void(*)(void))dec_mpd_qreduce, METH_VARARGS|METH_KEYWORDS, doc_normalize },
4913-
{ "to_integral", (PyCFunction)(void(*)(void))PyDec_ToIntegralValue, METH_VARARGS|METH_KEYWORDS, doc_to_integral },
4914-
{ "to_integral_exact", (PyCFunction)(void(*)(void))PyDec_ToIntegralExact, METH_VARARGS|METH_KEYWORDS, doc_to_integral_exact },
4915-
{ "to_integral_value", (PyCFunction)(void(*)(void))PyDec_ToIntegralValue, METH_VARARGS|METH_KEYWORDS, doc_to_integral_value },
4916-
{ "sqrt", (PyCFunction)(void(*)(void))dec_mpd_qsqrt, METH_VARARGS|METH_KEYWORDS, doc_sqrt },
4907+
{ "exp", _PyCFunction_CAST(dec_mpd_qexp), METH_VARARGS|METH_KEYWORDS, doc_exp },
4908+
{ "ln", _PyCFunction_CAST(dec_mpd_qln), METH_VARARGS|METH_KEYWORDS, doc_ln },
4909+
{ "log10", _PyCFunction_CAST(dec_mpd_qlog10), METH_VARARGS|METH_KEYWORDS, doc_log10 },
4910+
{ "next_minus", _PyCFunction_CAST(dec_mpd_qnext_minus), METH_VARARGS|METH_KEYWORDS, doc_next_minus },
4911+
{ "next_plus", _PyCFunction_CAST(dec_mpd_qnext_plus), METH_VARARGS|METH_KEYWORDS, doc_next_plus },
4912+
{ "normalize", _PyCFunction_CAST(dec_mpd_qreduce), METH_VARARGS|METH_KEYWORDS, doc_normalize },
4913+
{ "to_integral", _PyCFunction_CAST(PyDec_ToIntegralValue), METH_VARARGS|METH_KEYWORDS, doc_to_integral },
4914+
{ "to_integral_exact", _PyCFunction_CAST(PyDec_ToIntegralExact), METH_VARARGS|METH_KEYWORDS, doc_to_integral_exact },
4915+
{ "to_integral_value", _PyCFunction_CAST(PyDec_ToIntegralValue), METH_VARARGS|METH_KEYWORDS, doc_to_integral_value },
4916+
{ "sqrt", _PyCFunction_CAST(dec_mpd_qsqrt), METH_VARARGS|METH_KEYWORDS, doc_sqrt },
49174917

49184918
/* Binary arithmetic functions, optional context arg */
4919-
{ "compare", (PyCFunction)(void(*)(void))dec_mpd_qcompare, METH_VARARGS|METH_KEYWORDS, doc_compare },
4920-
{ "compare_signal", (PyCFunction)(void(*)(void))dec_mpd_qcompare_signal, METH_VARARGS|METH_KEYWORDS, doc_compare_signal },
4921-
{ "max", (PyCFunction)(void(*)(void))dec_mpd_qmax, METH_VARARGS|METH_KEYWORDS, doc_max },
4922-
{ "max_mag", (PyCFunction)(void(*)(void))dec_mpd_qmax_mag, METH_VARARGS|METH_KEYWORDS, doc_max_mag },
4923-
{ "min", (PyCFunction)(void(*)(void))dec_mpd_qmin, METH_VARARGS|METH_KEYWORDS, doc_min },
4924-
{ "min_mag", (PyCFunction)(void(*)(void))dec_mpd_qmin_mag, METH_VARARGS|METH_KEYWORDS, doc_min_mag },
4925-
{ "next_toward", (PyCFunction)(void(*)(void))dec_mpd_qnext_toward, METH_VARARGS|METH_KEYWORDS, doc_next_toward },
4926-
{ "quantize", (PyCFunction)(void(*)(void))dec_mpd_qquantize, METH_VARARGS|METH_KEYWORDS, doc_quantize },
4927-
{ "remainder_near", (PyCFunction)(void(*)(void))dec_mpd_qrem_near, METH_VARARGS|METH_KEYWORDS, doc_remainder_near },
4919+
{ "compare", _PyCFunction_CAST(dec_mpd_qcompare), METH_VARARGS|METH_KEYWORDS, doc_compare },
4920+
{ "compare_signal", _PyCFunction_CAST(dec_mpd_qcompare_signal), METH_VARARGS|METH_KEYWORDS, doc_compare_signal },
4921+
{ "max", _PyCFunction_CAST(dec_mpd_qmax), METH_VARARGS|METH_KEYWORDS, doc_max },
4922+
{ "max_mag", _PyCFunction_CAST(dec_mpd_qmax_mag), METH_VARARGS|METH_KEYWORDS, doc_max_mag },
4923+
{ "min", _PyCFunction_CAST(dec_mpd_qmin), METH_VARARGS|METH_KEYWORDS, doc_min },
4924+
{ "min_mag", _PyCFunction_CAST(dec_mpd_qmin_mag), METH_VARARGS|METH_KEYWORDS, doc_min_mag },
4925+
{ "next_toward", _PyCFunction_CAST(dec_mpd_qnext_toward), METH_VARARGS|METH_KEYWORDS, doc_next_toward },
4926+
{ "quantize", _PyCFunction_CAST(dec_mpd_qquantize), METH_VARARGS|METH_KEYWORDS, doc_quantize },
4927+
{ "remainder_near", _PyCFunction_CAST(dec_mpd_qrem_near), METH_VARARGS|METH_KEYWORDS, doc_remainder_near },
49284928

49294929
/* Ternary arithmetic functions, optional context arg */
4930-
{ "fma", (PyCFunction)(void(*)(void))dec_mpd_qfma, METH_VARARGS|METH_KEYWORDS, doc_fma },
4930+
{ "fma", _PyCFunction_CAST(dec_mpd_qfma), METH_VARARGS|METH_KEYWORDS, doc_fma },
49314931

49324932
/* Boolean functions, no context arg */
49334933
{ "is_canonical", dec_mpd_iscanonical, METH_NOARGS, doc_is_canonical },
@@ -4940,8 +4940,8 @@ static PyMethodDef dec_methods [] =
49404940
{ "is_zero", dec_mpd_iszero, METH_NOARGS, doc_is_zero },
49414941

49424942
/* Boolean functions, optional context arg */
4943-
{ "is_normal", (PyCFunction)(void(*)(void))dec_mpd_isnormal, METH_VARARGS|METH_KEYWORDS, doc_is_normal },
4944-
{ "is_subnormal", (PyCFunction)(void(*)(void))dec_mpd_issubnormal, METH_VARARGS|METH_KEYWORDS, doc_is_subnormal },
4943+
{ "is_normal", _PyCFunction_CAST(dec_mpd_isnormal), METH_VARARGS|METH_KEYWORDS, doc_is_normal },
4944+
{ "is_subnormal", _PyCFunction_CAST(dec_mpd_issubnormal), METH_VARARGS|METH_KEYWORDS, doc_is_subnormal },
49454945

49464946
/* Unary functions, no context arg */
49474947
{ "adjusted", dec_mpd_adjexp, METH_NOARGS, doc_adjusted },
@@ -4954,24 +4954,24 @@ static PyMethodDef dec_methods [] =
49544954
{ "copy_negate", dec_mpd_qcopy_negate, METH_NOARGS, doc_copy_negate },
49554955

49564956
/* Unary functions, optional context arg */
4957-
{ "logb", (PyCFunction)(void(*)(void))dec_mpd_qlogb, METH_VARARGS|METH_KEYWORDS, doc_logb },
4958-
{ "logical_invert", (PyCFunction)(void(*)(void))dec_mpd_qinvert, METH_VARARGS|METH_KEYWORDS, doc_logical_invert },
4959-
{ "number_class", (PyCFunction)(void(*)(void))dec_mpd_class, METH_VARARGS|METH_KEYWORDS, doc_number_class },
4960-
{ "to_eng_string", (PyCFunction)(void(*)(void))dec_mpd_to_eng, METH_VARARGS|METH_KEYWORDS, doc_to_eng_string },
4957+
{ "logb", _PyCFunction_CAST(dec_mpd_qlogb), METH_VARARGS|METH_KEYWORDS, doc_logb },
4958+
{ "logical_invert", _PyCFunction_CAST(dec_mpd_qinvert), METH_VARARGS|METH_KEYWORDS, doc_logical_invert },
4959+
{ "number_class", _PyCFunction_CAST(dec_mpd_class), METH_VARARGS|METH_KEYWORDS, doc_number_class },
4960+
{ "to_eng_string", _PyCFunction_CAST(dec_mpd_to_eng), METH_VARARGS|METH_KEYWORDS, doc_to_eng_string },
49614961

49624962
/* Binary functions, optional context arg for conversion errors */
4963-
{ "compare_total", (PyCFunction)(void(*)(void))dec_mpd_compare_total, METH_VARARGS|METH_KEYWORDS, doc_compare_total },
4964-
{ "compare_total_mag", (PyCFunction)(void(*)(void))dec_mpd_compare_total_mag, METH_VARARGS|METH_KEYWORDS, doc_compare_total_mag },
4965-
{ "copy_sign", (PyCFunction)(void(*)(void))dec_mpd_qcopy_sign, METH_VARARGS|METH_KEYWORDS, doc_copy_sign },
4966-
{ "same_quantum", (PyCFunction)(void(*)(void))dec_mpd_same_quantum, METH_VARARGS|METH_KEYWORDS, doc_same_quantum },
4963+
{ "compare_total", _PyCFunction_CAST(dec_mpd_compare_total), METH_VARARGS|METH_KEYWORDS, doc_compare_total },
4964+
{ "compare_total_mag", _PyCFunction_CAST(dec_mpd_compare_total_mag), METH_VARARGS|METH_KEYWORDS, doc_compare_total_mag },
4965+
{ "copy_sign", _PyCFunction_CAST(dec_mpd_qcopy_sign), METH_VARARGS|METH_KEYWORDS, doc_copy_sign },
4966+
{ "same_quantum", _PyCFunction_CAST(dec_mpd_same_quantum), METH_VARARGS|METH_KEYWORDS, doc_same_quantum },
49674967

49684968
/* Binary functions, optional context arg */
4969-
{ "logical_and", (PyCFunction)(void(*)(void))dec_mpd_qand, METH_VARARGS|METH_KEYWORDS, doc_logical_and },
4970-
{ "logical_or", (PyCFunction)(void(*)(void))dec_mpd_qor, METH_VARARGS|METH_KEYWORDS, doc_logical_or },
4971-
{ "logical_xor", (PyCFunction)(void(*)(void))dec_mpd_qxor, METH_VARARGS|METH_KEYWORDS, doc_logical_xor },
4972-
{ "rotate", (PyCFunction)(void(*)(void))dec_mpd_qrotate, METH_VARARGS|METH_KEYWORDS, doc_rotate },
4973-
{ "scaleb", (PyCFunction)(void(*)(void))dec_mpd_qscaleb, METH_VARARGS|METH_KEYWORDS, doc_scaleb },
4974-
{ "shift", (PyCFunction)(void(*)(void))dec_mpd_qshift, METH_VARARGS|METH_KEYWORDS, doc_shift },
4969+
{ "logical_and", _PyCFunction_CAST(dec_mpd_qand), METH_VARARGS|METH_KEYWORDS, doc_logical_and },
4970+
{ "logical_or", _PyCFunction_CAST(dec_mpd_qor), METH_VARARGS|METH_KEYWORDS, doc_logical_or },
4971+
{ "logical_xor", _PyCFunction_CAST(dec_mpd_qxor), METH_VARARGS|METH_KEYWORDS, doc_logical_xor },
4972+
{ "rotate", _PyCFunction_CAST(dec_mpd_qrotate), METH_VARARGS|METH_KEYWORDS, doc_rotate },
4973+
{ "scaleb", _PyCFunction_CAST(dec_mpd_qscaleb), METH_VARARGS|METH_KEYWORDS, doc_scaleb },
4974+
{ "shift", _PyCFunction_CAST(dec_mpd_qshift), METH_VARARGS|METH_KEYWORDS, doc_shift },
49754975

49764976
/* Miscellaneous */
49774977
{ "from_float", dec_from_float, METH_O|METH_CLASS, doc_from_float },
@@ -5609,7 +5609,7 @@ static PyMethodDef context_methods [] =
56095609
{ "subtract", ctx_mpd_qsub, METH_VARARGS, doc_ctx_subtract },
56105610

56115611
/* Binary or ternary arithmetic functions */
5612-
{ "power", (PyCFunction)(void(*)(void))ctx_mpd_qpow, METH_VARARGS|METH_KEYWORDS, doc_ctx_power },
5612+
{ "power", _PyCFunction_CAST(ctx_mpd_qpow), METH_VARARGS|METH_KEYWORDS, doc_ctx_power },
56135613

56145614
/* Ternary arithmetic functions */
56155615
{ "fma", ctx_mpd_qfma, METH_VARARGS, doc_ctx_fma },
@@ -5727,7 +5727,7 @@ static PyMethodDef _decimal_methods [] =
57275727
{
57285728
{ "getcontext", (PyCFunction)PyDec_GetCurrentContext, METH_NOARGS, doc_getcontext},
57295729
{ "setcontext", (PyCFunction)PyDec_SetCurrentContext, METH_O, doc_setcontext},
5730-
{ "localcontext", (PyCFunction)(void(*)(void))ctxmanager_new, METH_VARARGS|METH_KEYWORDS, doc_localcontext},
5730+
{ "localcontext", _PyCFunction_CAST(ctxmanager_new), METH_VARARGS|METH_KEYWORDS, doc_localcontext},
57315731
#ifdef EXTRA_FUNCTIONALITY
57325732
{ "IEEEContext", (PyCFunction)ieee_context, METH_O, doc_ieee_context},
57335733
#endif

Modules/_elementtree.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -4349,7 +4349,7 @@ static PyTypeObject XMLParser_Type = {
43494349
/* python module interface */
43504350

43514351
static PyMethodDef _functions[] = {
4352-
{"SubElement", (PyCFunction)(void(*)(void)) subelement, METH_VARARGS | METH_KEYWORDS},
4352+
{"SubElement", _PyCFunction_CAST(subelement), METH_VARARGS | METH_KEYWORDS},
43534353
_ELEMENTTREE__SET_FACTORIES_METHODDEF
43544354
{NULL, NULL}
43554355
};

Modules/_functoolsmodule.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -1432,7 +1432,7 @@ PyDoc_STRVAR(_functools_doc,
14321432

14331433
static PyMethodDef _functools_methods[] = {
14341434
{"reduce", functools_reduce, METH_VARARGS, functools_reduce_doc},
1435-
{"cmp_to_key", (PyCFunction)(void(*)(void))functools_cmp_to_key,
1435+
{"cmp_to_key", _PyCFunction_CAST(functools_cmp_to_key),
14361436
METH_VARARGS | METH_KEYWORDS, functools_cmp_to_key_doc},
14371437
{NULL, NULL} /* sentinel */
14381438
};

Modules/_lsprof.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,7 @@ profiler_init(ProfilerObject *pObj, PyObject *args, PyObject *kw)
787787

788788
static PyMethodDef profiler_methods[] = {
789789
_LSPROF_PROFILER_GETSTATS_METHODDEF
790-
{"enable", (PyCFunction)(void(*)(void))profiler_enable,
790+
{"enable", _PyCFunction_CAST(profiler_enable),
791791
METH_VARARGS | METH_KEYWORDS, enable_doc},
792792
{"disable", (PyCFunction)profiler_disable,
793793
METH_NOARGS, disable_doc},

Modules/_operator.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -893,7 +893,7 @@ PyDoc_STRVAR(_operator_call__doc__,
893893
"Same as obj(*args, **kwargs).");
894894

895895
#define _OPERATOR_CALL_METHODDEF \
896-
{"call", (PyCFunction)(void(*)(void))_operator_call, METH_FASTCALL | METH_KEYWORDS, _operator_call__doc__},
896+
{"call", _PyCFunction_CAST(_operator_call), METH_FASTCALL | METH_KEYWORDS, _operator_call__doc__},
897897

898898
static PyObject *
899899
_operator_call(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject *kwnames)

Modules/_struct.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -2049,8 +2049,8 @@ s_sizeof(PyStructObject *self, void *unused)
20492049

20502050
static struct PyMethodDef s_methods[] = {
20512051
STRUCT_ITER_UNPACK_METHODDEF
2052-
{"pack", (PyCFunction)(void(*)(void))s_pack, METH_FASTCALL, s_pack__doc__},
2053-
{"pack_into", (PyCFunction)(void(*)(void))s_pack_into, METH_FASTCALL, s_pack_into__doc__},
2052+
{"pack", _PyCFunction_CAST(s_pack), METH_FASTCALL, s_pack__doc__},
2053+
{"pack_into", _PyCFunction_CAST(s_pack_into), METH_FASTCALL, s_pack_into__doc__},
20542054
STRUCT_UNPACK_METHODDEF
20552055
STRUCT_UNPACK_FROM_METHODDEF
20562056
{"__sizeof__", (PyCFunction)s_sizeof, METH_NOARGS, s_sizeof__doc__},
@@ -2298,8 +2298,8 @@ static struct PyMethodDef module_functions[] = {
22982298
_CLEARCACHE_METHODDEF
22992299
CALCSIZE_METHODDEF
23002300
ITER_UNPACK_METHODDEF
2301-
{"pack", (PyCFunction)(void(*)(void))pack, METH_FASTCALL, pack_doc},
2302-
{"pack_into", (PyCFunction)(void(*)(void))pack_into, METH_FASTCALL, pack_into_doc},
2301+
{"pack", _PyCFunction_CAST(pack), METH_FASTCALL, pack_doc},
2302+
{"pack_into", _PyCFunction_CAST(pack_into), METH_FASTCALL, pack_into_doc},
23032303
UNPACK_METHODDEF
23042304
UNPACK_FROM_METHODDEF
23052305
{NULL, NULL} /* sentinel */

0 commit comments

Comments
 (0)