Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e365fb8

Browse files
committed
Use METH_VARARGS instead of numeric constant 1 in method def. tables
1 parent 14f5158 commit e365fb8

12 files changed

Lines changed: 179 additions & 108 deletions

Modules/_localemodule.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -389,10 +389,14 @@ PyLocale_getdefaultlocale(PyObject* self, PyObject* args)
389389
#endif
390390

391391
static struct PyMethodDef PyLocale_Methods[] = {
392-
{"setlocale", (PyCFunction) PyLocale_setlocale, 1, setlocale__doc__},
393-
{"localeconv", (PyCFunction) PyLocale_localeconv, 0, localeconv__doc__},
394-
{"strcoll", (PyCFunction) PyLocale_strcoll, 1, strcoll__doc__},
395-
{"strxfrm", (PyCFunction) PyLocale_strxfrm, 1, strxfrm__doc__},
392+
{"setlocale", (PyCFunction) PyLocale_setlocale,
393+
METH_VARARGS, setlocale__doc__},
394+
{"localeconv", (PyCFunction) PyLocale_localeconv,
395+
0, localeconv__doc__},
396+
{"strcoll", (PyCFunction) PyLocale_strcoll,
397+
METH_VARARGS, strcoll__doc__},
398+
{"strxfrm", (PyCFunction) PyLocale_strxfrm,
399+
METH_VARARGS, strxfrm__doc__},
396400
#if defined(MS_WIN32) || defined(macintosh)
397401
{"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, 0},
398402
#endif

Modules/binascii.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -877,20 +877,27 @@ binascii_crc32(PyObject *self, PyObject *args)
877877
/* List of functions defined in the module */
878878

879879
static struct PyMethodDef binascii_module_methods[] = {
880-
{"a2b_uu", binascii_a2b_uu, 1, doc_a2b_uu},
881-
{"b2a_uu", binascii_b2a_uu, 1, doc_b2a_uu},
882-
{"a2b_base64", binascii_a2b_base64, 1,
880+
{"a2b_uu", binascii_a2b_uu,
881+
METH_VARARGS, doc_a2b_uu},
882+
{"b2a_uu", binascii_b2a_uu,
883+
METH_VARARGS, doc_b2a_uu},
884+
{"a2b_base64", binascii_a2b_base64,
885+
METH_VARARGS,
883886
doc_a2b_base64},
884-
{"b2a_base64", binascii_b2a_base64, 1,
885-
doc_b2a_base64},
886-
{"a2b_hqx", binascii_a2b_hqx, 1, doc_a2b_hqx},
887-
{"b2a_hqx", binascii_b2a_hqx, 1, doc_b2a_hqx},
888-
{"rlecode_hqx", binascii_rlecode_hqx, 1,
889-
doc_rlecode_hqx},
890-
{"rledecode_hqx", binascii_rledecode_hqx, 1,
891-
doc_rledecode_hqx},
892-
{"crc_hqx", binascii_crc_hqx, 1, doc_crc_hqx},
893-
{"crc32", binascii_crc32, 1, doc_crc32},
887+
{"b2a_base64", binascii_b2a_base64,
888+
METH_VARARGS, doc_b2a_base64},
889+
{"a2b_hqx", binascii_a2b_hqx,
890+
METH_VARARGS, doc_a2b_hqx},
891+
{"b2a_hqx", binascii_b2a_hqx,
892+
METH_VARARGS, doc_b2a_hqx},
893+
{"rlecode_hqx", binascii_rlecode_hqx,
894+
METH_VARARGS, doc_rlecode_hqx},
895+
{"rledecode_hqx", binascii_rledecode_hqx,
896+
METH_VARARGS, doc_rledecode_hqx},
897+
{"crc_hqx", binascii_crc_hqx,
898+
METH_VARARGS, doc_crc_hqx},
899+
{"crc32", binascii_crc32,
900+
METH_VARARGS, doc_crc32},
894901
{NULL, NULL} /* sentinel */
895902
};
896903

Modules/cStringIO.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -617,7 +617,8 @@ IO_StringIO(PyObject *self, PyObject *args) {
617617
/* List of methods defined in the module */
618618

619619
static struct PyMethodDef IO_methods[] = {
620-
{"StringIO", (PyCFunction)IO_StringIO, 1, IO_StringIO__doc__},
620+
{"StringIO", (PyCFunction)IO_StringIO,
621+
METH_VARARGS, IO_StringIO__doc__},
621622
{NULL, NULL} /* sentinel */
622623
};
623624

Modules/cmathmodule.c

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -372,22 +372,38 @@ functions for complex numbers.";
372372

373373

374374
static PyMethodDef cmath_methods[] = {
375-
{"acos", cmath_acos, 1, c_acos_doc},
376-
{"acosh", cmath_acosh, 1, c_acosh_doc},
377-
{"asin", cmath_asin, 1, c_asin_doc},
378-
{"asinh", cmath_asinh, 1, c_asinh_doc},
379-
{"atan", cmath_atan, 1, c_atan_doc},
380-
{"atanh", cmath_atanh, 1, c_atanh_doc},
381-
{"cos", cmath_cos, 1, c_cos_doc},
382-
{"cosh", cmath_cosh, 1, c_cosh_doc},
383-
{"exp", cmath_exp, 1, c_exp_doc},
384-
{"log", cmath_log, 1, c_log_doc},
385-
{"log10", cmath_log10, 1, c_log10_doc},
386-
{"sin", cmath_sin, 1, c_sin_doc},
387-
{"sinh", cmath_sinh, 1, c_sinh_doc},
388-
{"sqrt", cmath_sqrt, 1, c_sqrt_doc},
389-
{"tan", cmath_tan, 1, c_tan_doc},
390-
{"tanh", cmath_tanh, 1, c_tanh_doc},
375+
{"acos", cmath_acos,
376+
METH_VARARGS, c_acos_doc},
377+
{"acosh", cmath_acosh,
378+
METH_VARARGS, c_acosh_doc},
379+
{"asin", cmath_asin,
380+
METH_VARARGS, c_asin_doc},
381+
{"asinh", cmath_asinh,
382+
METH_VARARGS, c_asinh_doc},
383+
{"atan", cmath_atan,
384+
METH_VARARGS, c_atan_doc},
385+
{"atanh", cmath_atanh,
386+
METH_VARARGS, c_atanh_doc},
387+
{"cos", cmath_cos,
388+
METH_VARARGS, c_cos_doc},
389+
{"cosh", cmath_cosh,
390+
METH_VARARGS, c_cosh_doc},
391+
{"exp", cmath_exp,
392+
METH_VARARGS, c_exp_doc},
393+
{"log", cmath_log,
394+
METH_VARARGS, c_log_doc},
395+
{"log10", cmath_log10,
396+
METH_VARARGS, c_log10_doc},
397+
{"sin", cmath_sin,
398+
METH_VARARGS, c_sin_doc},
399+
{"sinh", cmath_sinh,
400+
METH_VARARGS, c_sinh_doc},
401+
{"sqrt", cmath_sqrt,
402+
METH_VARARGS, c_sqrt_doc},
403+
{"tan", cmath_tan,
404+
METH_VARARGS, c_tan_doc},
405+
{"tanh", cmath_tanh,
406+
METH_VARARGS, c_tanh_doc},
391407
{NULL, NULL} /* sentinel */
392408
};
393409

Modules/md5module.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -227,8 +227,8 @@ is made.";
227227
/* List of functions exported by this module */
228228

229229
static PyMethodDef md5_functions[] = {
230-
{"new", (PyCFunction)MD5_new, 1, new_doc},
231-
{"md5", (PyCFunction)MD5_new, 1, new_doc}, /* Backward compatibility */
230+
{"new", (PyCFunction)MD5_new, METH_VARARGS, new_doc},
231+
{"md5", (PyCFunction)MD5_new, METH_VARARGS, new_doc}, /* Backward compatibility */
232232
{NULL, NULL} /* Sentinel */
233233
};
234234

Modules/newmodule.c

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,12 +180,18 @@ new_class(PyObject* unused, PyObject* args)
180180
}
181181

182182
static PyMethodDef new_methods[] = {
183-
{"instance", new_instance, 1, new_instance_doc},
184-
{"instancemethod", new_instancemethod, 1, new_im_doc},
185-
{"function", new_function, 1, new_function_doc},
186-
{"code", new_code, 1, new_code_doc},
187-
{"module", new_module, 1, new_module_doc},
188-
{"classobj", new_class, 1, new_class_doc},
183+
{"instance", new_instance,
184+
METH_VARARGS, new_instance_doc},
185+
{"instancemethod", new_instancemethod,
186+
METH_VARARGS, new_im_doc},
187+
{"function", new_function,
188+
METH_VARARGS, new_function_doc},
189+
{"code", new_code,
190+
METH_VARARGS, new_code_doc},
191+
{"module", new_module,
192+
METH_VARARGS, new_module_doc},
193+
{"classobj", new_class,
194+
METH_VARARGS, new_class_doc},
189195
{NULL, NULL} /* sentinel */
190196
};
191197

Modules/readline.c

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -323,15 +323,19 @@ Insert text into the command line.\
323323

324324
static struct PyMethodDef readline_methods[] =
325325
{
326-
{"parse_and_bind", parse_and_bind, 1, doc_parse_and_bind},
326+
{"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind},
327327
{"get_line_buffer", get_line_buffer, 0, doc_get_line_buffer},
328-
{"insert_text", insert_text, 1, doc_insert_text},
329-
{"read_init_file", read_init_file, 1, doc_read_init_file},
330-
{"read_history_file", read_history_file, 1, doc_read_history_file},
331-
{"write_history_file", write_history_file, 1, doc_write_history_file},
332-
{"set_history_length", set_history_length, 1, set_history_length_doc},
333-
{"get_history_length", get_history_length, 1, get_history_length_doc},
334-
{"set_completer", set_completer, 1, doc_set_completer},
328+
{"insert_text", insert_text, METH_VARARGS, doc_insert_text},
329+
{"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file},
330+
{"read_history_file", read_history_file,
331+
METH_VARARGS, doc_read_history_file},
332+
{"write_history_file", write_history_file,
333+
METH_VARARGS, doc_write_history_file},
334+
{"set_history_length", set_history_length,
335+
METH_VARARGS, set_history_length_doc},
336+
{"get_history_length", get_history_length,
337+
METH_VARARGS, get_history_length_doc},
338+
{"set_completer", set_completer, METH_VARARGS, doc_set_completer},
335339
{"get_begidx", get_begidx, 0, doc_get_begidx},
336340
{"get_endidx", get_endidx, 0, doc_get_endidx},
337341

Modules/socketmodule.c

Lines changed: 50 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1344,49 +1344,49 @@ of the socket (flag == 1), or both ends (flag == 2).";
13441344
/* List of methods for socket objects */
13451345

13461346
static PyMethodDef PySocketSock_methods[] = {
1347-
{"accept", (PyCFunction)PySocketSock_accept, 1,
1347+
{"accept", (PyCFunction)PySocketSock_accept, METH_VARARGS,
13481348
accept_doc},
1349-
{"bind", (PyCFunction)PySocketSock_bind, 1,
1349+
{"bind", (PyCFunction)PySocketSock_bind, METH_VARARGS,
13501350
bind_doc},
1351-
{"close", (PyCFunction)PySocketSock_close, 1,
1351+
{"close", (PyCFunction)PySocketSock_close, METH_VARARGS,
13521352
close_doc},
1353-
{"connect", (PyCFunction)PySocketSock_connect, 1,
1353+
{"connect", (PyCFunction)PySocketSock_connect, METH_VARARGS,
13541354
connect_doc},
1355-
{"connect_ex", (PyCFunction)PySocketSock_connect_ex, 1,
1355+
{"connect_ex", (PyCFunction)PySocketSock_connect_ex, METH_VARARGS,
13561356
connect_ex_doc},
13571357
#ifndef NO_DUP
1358-
{"dup", (PyCFunction)PySocketSock_dup, 1,
1358+
{"dup", (PyCFunction)PySocketSock_dup, METH_VARARGS,
13591359
dup_doc},
13601360
#endif
1361-
{"fileno", (PyCFunction)PySocketSock_fileno, 1,
1361+
{"fileno", (PyCFunction)PySocketSock_fileno, METH_VARARGS,
13621362
fileno_doc},
13631363
#ifdef HAVE_GETPEERNAME
1364-
{"getpeername", (PyCFunction)PySocketSock_getpeername, 1,
1364+
{"getpeername", (PyCFunction)PySocketSock_getpeername, METH_VARARGS,
13651365
getpeername_doc},
13661366
#endif
1367-
{"getsockname", (PyCFunction)PySocketSock_getsockname, 1,
1367+
{"getsockname", (PyCFunction)PySocketSock_getsockname, METH_VARARGS,
13681368
getsockname_doc},
1369-
{"getsockopt", (PyCFunction)PySocketSock_getsockopt, 1,
1369+
{"getsockopt", (PyCFunction)PySocketSock_getsockopt, METH_VARARGS,
13701370
getsockopt_doc},
1371-
{"listen", (PyCFunction)PySocketSock_listen, 1,
1371+
{"listen", (PyCFunction)PySocketSock_listen, METH_VARARGS,
13721372
listen_doc},
13731373
#ifndef NO_DUP
1374-
{"makefile", (PyCFunction)PySocketSock_makefile, 1,
1374+
{"makefile", (PyCFunction)PySocketSock_makefile, METH_VARARGS,
13751375
makefile_doc},
13761376
#endif
1377-
{"recv", (PyCFunction)PySocketSock_recv, 1,
1377+
{"recv", (PyCFunction)PySocketSock_recv, METH_VARARGS,
13781378
recv_doc},
1379-
{"recvfrom", (PyCFunction)PySocketSock_recvfrom, 1,
1379+
{"recvfrom", (PyCFunction)PySocketSock_recvfrom, METH_VARARGS,
13801380
recvfrom_doc},
1381-
{"send", (PyCFunction)PySocketSock_send, 1,
1381+
{"send", (PyCFunction)PySocketSock_send, METH_VARARGS,
13821382
send_doc},
1383-
{"sendto", (PyCFunction)PySocketSock_sendto, 1,
1383+
{"sendto", (PyCFunction)PySocketSock_sendto, METH_VARARGS,
13841384
sendto_doc},
1385-
{"setblocking", (PyCFunction)PySocketSock_setblocking, 1,
1385+
{"setblocking", (PyCFunction)PySocketSock_setblocking, METH_VARARGS,
13861386
setblocking_doc},
1387-
{"setsockopt", (PyCFunction)PySocketSock_setsockopt, 1,
1387+
{"setsockopt", (PyCFunction)PySocketSock_setsockopt, METH_VARARGS,
13881388
setsockopt_doc},
1389-
{"shutdown", (PyCFunction)PySocketSock_shutdown, 1,
1389+
{"shutdown", (PyCFunction)PySocketSock_shutdown, METH_VARARGS,
13901390
shutdown_doc},
13911391
{NULL, NULL} /* sentinel */
13921392
};
@@ -2199,24 +2199,39 @@ static PyObject *SSL_SSLread(SSLObject *self, PyObject *args)
21992199
/* List of functions exported by this module. */
22002200

22012201
static PyMethodDef PySocket_methods[] = {
2202-
{"gethostbyname", PySocket_gethostbyname, 1, gethostbyname_doc},
2203-
{"gethostbyname_ex", PySocket_gethostbyname_ex, 1, ghbn_ex_doc},
2204-
{"gethostbyaddr", PySocket_gethostbyaddr, 1, gethostbyaddr_doc},
2205-
{"gethostname", PySocket_gethostname, 1, gethostname_doc},
2206-
{"getservbyname", PySocket_getservbyname, 1, getservbyname_doc},
2207-
{"getprotobyname", PySocket_getprotobyname, 1,getprotobyname_doc},
2208-
{"socket", PySocket_socket, 1, socket_doc},
2202+
{"gethostbyname", PySocket_gethostbyname,
2203+
METH_VARARGS, gethostbyname_doc},
2204+
{"gethostbyname_ex", PySocket_gethostbyname_ex,
2205+
METH_VARARGS, ghbn_ex_doc},
2206+
{"gethostbyaddr", PySocket_gethostbyaddr,
2207+
METH_VARARGS, gethostbyaddr_doc},
2208+
{"gethostname", PySocket_gethostname,
2209+
METH_VARARGS, gethostname_doc},
2210+
{"getservbyname", PySocket_getservbyname,
2211+
METH_VARARGS, getservbyname_doc},
2212+
{"getprotobyname", PySocket_getprotobyname,
2213+
METH_VARARGS,getprotobyname_doc},
2214+
{"socket", PySocket_socket,
2215+
METH_VARARGS, socket_doc},
22092216
#ifndef NO_DUP
2210-
{"fromfd", PySocket_fromfd, 1, fromfd_doc},
2211-
#endif
2212-
{"ntohs", PySocket_ntohs, 1, ntohs_doc},
2213-
{"ntohl", PySocket_ntohl, 1, ntohl_doc},
2214-
{"htons", PySocket_htons, 1, htons_doc},
2215-
{"htonl", PySocket_htonl, 1, htonl_doc},
2216-
{"inet_aton", PySocket_inet_aton, 1, inet_aton_doc},
2217-
{"inet_ntoa", PySocket_inet_ntoa, 1, inet_ntoa_doc},
2217+
{"fromfd", PySocket_fromfd,
2218+
METH_VARARGS, fromfd_doc},
2219+
#endif
2220+
{"ntohs", PySocket_ntohs,
2221+
METH_VARARGS, ntohs_doc},
2222+
{"ntohl", PySocket_ntohl,
2223+
METH_VARARGS, ntohl_doc},
2224+
{"htons", PySocket_htons,
2225+
METH_VARARGS, htons_doc},
2226+
{"htonl", PySocket_htonl,
2227+
METH_VARARGS, htonl_doc},
2228+
{"inet_aton", PySocket_inet_aton,
2229+
METH_VARARGS, inet_aton_doc},
2230+
{"inet_ntoa", PySocket_inet_ntoa,
2231+
METH_VARARGS, inet_ntoa_doc},
22182232
#ifdef USE_SSL
2219-
{"ssl", PySocket_ssl, 1, ssl_doc},
2233+
{"ssl", PySocket_ssl,
2234+
METH_VARARGS, ssl_doc},
22202235
#endif /* USE_SSL */
22212236
{NULL, NULL} /* Sentinel */
22222237
};

Modules/soundex.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@ sound_similar(PyObject *self, PyObject *args)
157157
*/
158158
static PyMethodDef SoundexMethods[] =
159159
{
160-
{"sound_similar", sound_similar, 1, soundex_sound_similar__doc__},
161-
{"get_soundex", get_soundex, 1, soundex_get_soundex__doc__},
160+
{"sound_similar", sound_similar,
161+
METH_VARARGS, soundex_sound_similar__doc__},
162+
{"get_soundex", get_soundex,
163+
METH_VARARGS, soundex_get_soundex__doc__},
162164

163-
{NULL, NULL } /* sentinel */
165+
{NULL, NULL } /* sentinel */
164166
};
165167

166168

Modules/stropmodule.c

Lines changed: 28 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,26 +1154,40 @@ strop_replace(PyObject *self, PyObject *args)
11541154

11551155
static PyMethodDef
11561156
strop_methods[] = {
1157-
{"atof", strop_atof, 1, atof__doc__},
1158-
{"atoi", strop_atoi, 1, atoi__doc__},
1159-
{"atol", strop_atol, 1, atol__doc__},
1157+
{"atof", strop_atof,
1158+
METH_VARARGS, atof__doc__},
1159+
{"atoi", strop_atoi,
1160+
METH_VARARGS, atoi__doc__},
1161+
{"atol", strop_atol,
1162+
METH_VARARGS, atol__doc__},
11601163
{"capitalize", strop_capitalize, 0, capitalize__doc__},
1161-
{"count", strop_count, 1, count__doc__},
1162-
{"expandtabs", strop_expandtabs, 1, expandtabs__doc__},
1163-
{"find", strop_find, 1, find__doc__},
1164-
{"join", strop_joinfields, 1, joinfields__doc__},
1165-
{"joinfields", strop_joinfields, 1, joinfields__doc__},
1164+
{"count", strop_count,
1165+
METH_VARARGS, count__doc__},
1166+
{"expandtabs", strop_expandtabs,
1167+
METH_VARARGS, expandtabs__doc__},
1168+
{"find", strop_find,
1169+
METH_VARARGS, find__doc__},
1170+
{"join", strop_joinfields,
1171+
METH_VARARGS, joinfields__doc__},
1172+
{"joinfields", strop_joinfields,
1173+
METH_VARARGS, joinfields__doc__},
11661174
{"lstrip", strop_lstrip, 0, lstrip__doc__},
11671175
{"lower", strop_lower, 0, lower__doc__},
1168-
{"maketrans", strop_maketrans, 1, maketrans__doc__},
1169-
{"replace", strop_replace, 1, replace__doc__},
1170-
{"rfind", strop_rfind, 1, rfind__doc__},
1176+
{"maketrans", strop_maketrans,
1177+
METH_VARARGS, maketrans__doc__},
1178+
{"replace", strop_replace,
1179+
METH_VARARGS, replace__doc__},
1180+
{"rfind", strop_rfind,
1181+
METH_VARARGS, rfind__doc__},
11711182
{"rstrip", strop_rstrip, 0, rstrip__doc__},
1172-
{"split", strop_splitfields, 1, splitfields__doc__},
1173-
{"splitfields", strop_splitfields, 1, splitfields__doc__},
1183+
{"split", strop_splitfields,
1184+
METH_VARARGS, splitfields__doc__},
1185+
{"splitfields", strop_splitfields,
1186+
METH_VARARGS, splitfields__doc__},
11741187
{"strip", strop_strip, 0, strip__doc__},
11751188
{"swapcase", strop_swapcase, 0, swapcase__doc__},
1176-
{"translate", strop_translate, 1, translate__doc__},
1189+
{"translate", strop_translate,
1190+
METH_VARARGS, translate__doc__},
11771191
{"upper", strop_upper, 0, upper__doc__},
11781192
{NULL, NULL} /* sentinel */
11791193
};

0 commit comments

Comments
 (0)