From e365fb8d1ff062d619f9476265e48e9ba8ab2bf6 Mon Sep 17 00:00:00 2001 From: "Andrew M. Kuchling" Date: Thu, 3 Aug 2000 02:06:16 +0000 Subject: [PATCH] Use METH_VARARGS instead of numeric constant 1 in method def. tables --- Modules/_localemodule.c | 12 ++++-- Modules/binascii.c | 33 +++++++++------- Modules/cStringIO.c | 3 +- Modules/cmathmodule.c | 48 ++++++++++++++++-------- Modules/md5module.c | 4 +- Modules/newmodule.c | 18 ++++++--- Modules/readline.c | 20 ++++++---- Modules/socketmodule.c | 83 ++++++++++++++++++++++++----------------- Modules/soundex.c | 8 ++-- Modules/stropmodule.c | 42 ++++++++++++++------- Modules/threadmodule.c | 6 ++- Modules/timemodule.c | 8 ++-- 12 files changed, 178 insertions(+), 107 deletions(-) diff --git a/Modules/_localemodule.c b/Modules/_localemodule.c index 4362ffd3b52..0ea95e4f4d5 100644 --- a/Modules/_localemodule.c +++ b/Modules/_localemodule.c @@ -389,10 +389,14 @@ PyLocale_getdefaultlocale(PyObject* self, PyObject* args) #endif static struct PyMethodDef PyLocale_Methods[] = { - {"setlocale", (PyCFunction) PyLocale_setlocale, 1, setlocale__doc__}, - {"localeconv", (PyCFunction) PyLocale_localeconv, 0, localeconv__doc__}, - {"strcoll", (PyCFunction) PyLocale_strcoll, 1, strcoll__doc__}, - {"strxfrm", (PyCFunction) PyLocale_strxfrm, 1, strxfrm__doc__}, + {"setlocale", (PyCFunction) PyLocale_setlocale, + METH_VARARGS, setlocale__doc__}, + {"localeconv", (PyCFunction) PyLocale_localeconv, + 0, localeconv__doc__}, + {"strcoll", (PyCFunction) PyLocale_strcoll, + METH_VARARGS, strcoll__doc__}, + {"strxfrm", (PyCFunction) PyLocale_strxfrm, + METH_VARARGS, strxfrm__doc__}, #if defined(MS_WIN32) || defined(macintosh) {"_getdefaultlocale", (PyCFunction) PyLocale_getdefaultlocale, 0}, #endif diff --git a/Modules/binascii.c b/Modules/binascii.c index 5c9944ac5e1..50f8b76044b 100644 --- a/Modules/binascii.c +++ b/Modules/binascii.c @@ -877,20 +877,27 @@ binascii_crc32(PyObject *self, PyObject *args) /* List of functions defined in the module */ static struct PyMethodDef binascii_module_methods[] = { - {"a2b_uu", binascii_a2b_uu, 1, doc_a2b_uu}, - {"b2a_uu", binascii_b2a_uu, 1, doc_b2a_uu}, - {"a2b_base64", binascii_a2b_base64, 1, + {"a2b_uu", binascii_a2b_uu, + METH_VARARGS, doc_a2b_uu}, + {"b2a_uu", binascii_b2a_uu, + METH_VARARGS, doc_b2a_uu}, + {"a2b_base64", binascii_a2b_base64, + METH_VARARGS, doc_a2b_base64}, - {"b2a_base64", binascii_b2a_base64, 1, - doc_b2a_base64}, - {"a2b_hqx", binascii_a2b_hqx, 1, doc_a2b_hqx}, - {"b2a_hqx", binascii_b2a_hqx, 1, doc_b2a_hqx}, - {"rlecode_hqx", binascii_rlecode_hqx, 1, - doc_rlecode_hqx}, - {"rledecode_hqx", binascii_rledecode_hqx, 1, - doc_rledecode_hqx}, - {"crc_hqx", binascii_crc_hqx, 1, doc_crc_hqx}, - {"crc32", binascii_crc32, 1, doc_crc32}, + {"b2a_base64", binascii_b2a_base64, + METH_VARARGS, doc_b2a_base64}, + {"a2b_hqx", binascii_a2b_hqx, + METH_VARARGS, doc_a2b_hqx}, + {"b2a_hqx", binascii_b2a_hqx, + METH_VARARGS, doc_b2a_hqx}, + {"rlecode_hqx", binascii_rlecode_hqx, + METH_VARARGS, doc_rlecode_hqx}, + {"rledecode_hqx", binascii_rledecode_hqx, + METH_VARARGS, doc_rledecode_hqx}, + {"crc_hqx", binascii_crc_hqx, + METH_VARARGS, doc_crc_hqx}, + {"crc32", binascii_crc32, + METH_VARARGS, doc_crc32}, {NULL, NULL} /* sentinel */ }; diff --git a/Modules/cStringIO.c b/Modules/cStringIO.c index 5be59f47846..749ebcb4d90 100644 --- a/Modules/cStringIO.c +++ b/Modules/cStringIO.c @@ -617,7 +617,8 @@ IO_StringIO(PyObject *self, PyObject *args) { /* List of methods defined in the module */ static struct PyMethodDef IO_methods[] = { - {"StringIO", (PyCFunction)IO_StringIO, 1, IO_StringIO__doc__}, + {"StringIO", (PyCFunction)IO_StringIO, + METH_VARARGS, IO_StringIO__doc__}, {NULL, NULL} /* sentinel */ }; diff --git a/Modules/cmathmodule.c b/Modules/cmathmodule.c index 97819838b3f..69eaf128701 100644 --- a/Modules/cmathmodule.c +++ b/Modules/cmathmodule.c @@ -372,22 +372,38 @@ functions for complex numbers."; static PyMethodDef cmath_methods[] = { - {"acos", cmath_acos, 1, c_acos_doc}, - {"acosh", cmath_acosh, 1, c_acosh_doc}, - {"asin", cmath_asin, 1, c_asin_doc}, - {"asinh", cmath_asinh, 1, c_asinh_doc}, - {"atan", cmath_atan, 1, c_atan_doc}, - {"atanh", cmath_atanh, 1, c_atanh_doc}, - {"cos", cmath_cos, 1, c_cos_doc}, - {"cosh", cmath_cosh, 1, c_cosh_doc}, - {"exp", cmath_exp, 1, c_exp_doc}, - {"log", cmath_log, 1, c_log_doc}, - {"log10", cmath_log10, 1, c_log10_doc}, - {"sin", cmath_sin, 1, c_sin_doc}, - {"sinh", cmath_sinh, 1, c_sinh_doc}, - {"sqrt", cmath_sqrt, 1, c_sqrt_doc}, - {"tan", cmath_tan, 1, c_tan_doc}, - {"tanh", cmath_tanh, 1, c_tanh_doc}, + {"acos", cmath_acos, + METH_VARARGS, c_acos_doc}, + {"acosh", cmath_acosh, + METH_VARARGS, c_acosh_doc}, + {"asin", cmath_asin, + METH_VARARGS, c_asin_doc}, + {"asinh", cmath_asinh, + METH_VARARGS, c_asinh_doc}, + {"atan", cmath_atan, + METH_VARARGS, c_atan_doc}, + {"atanh", cmath_atanh, + METH_VARARGS, c_atanh_doc}, + {"cos", cmath_cos, + METH_VARARGS, c_cos_doc}, + {"cosh", cmath_cosh, + METH_VARARGS, c_cosh_doc}, + {"exp", cmath_exp, + METH_VARARGS, c_exp_doc}, + {"log", cmath_log, + METH_VARARGS, c_log_doc}, + {"log10", cmath_log10, + METH_VARARGS, c_log10_doc}, + {"sin", cmath_sin, + METH_VARARGS, c_sin_doc}, + {"sinh", cmath_sinh, + METH_VARARGS, c_sinh_doc}, + {"sqrt", cmath_sqrt, + METH_VARARGS, c_sqrt_doc}, + {"tan", cmath_tan, + METH_VARARGS, c_tan_doc}, + {"tanh", cmath_tanh, + METH_VARARGS, c_tanh_doc}, {NULL, NULL} /* sentinel */ }; diff --git a/Modules/md5module.c b/Modules/md5module.c index 59e4c6c269c..78a2b451240 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -227,8 +227,8 @@ is made."; /* List of functions exported by this module */ static PyMethodDef md5_functions[] = { - {"new", (PyCFunction)MD5_new, 1, new_doc}, - {"md5", (PyCFunction)MD5_new, 1, new_doc}, /* Backward compatibility */ + {"new", (PyCFunction)MD5_new, METH_VARARGS, new_doc}, + {"md5", (PyCFunction)MD5_new, METH_VARARGS, new_doc}, /* Backward compatibility */ {NULL, NULL} /* Sentinel */ }; diff --git a/Modules/newmodule.c b/Modules/newmodule.c index 3ebac7fb293..1595c0c64c3 100644 --- a/Modules/newmodule.c +++ b/Modules/newmodule.c @@ -180,12 +180,18 @@ new_class(PyObject* unused, PyObject* args) } static PyMethodDef new_methods[] = { - {"instance", new_instance, 1, new_instance_doc}, - {"instancemethod", new_instancemethod, 1, new_im_doc}, - {"function", new_function, 1, new_function_doc}, - {"code", new_code, 1, new_code_doc}, - {"module", new_module, 1, new_module_doc}, - {"classobj", new_class, 1, new_class_doc}, + {"instance", new_instance, + METH_VARARGS, new_instance_doc}, + {"instancemethod", new_instancemethod, + METH_VARARGS, new_im_doc}, + {"function", new_function, + METH_VARARGS, new_function_doc}, + {"code", new_code, + METH_VARARGS, new_code_doc}, + {"module", new_module, + METH_VARARGS, new_module_doc}, + {"classobj", new_class, + METH_VARARGS, new_class_doc}, {NULL, NULL} /* sentinel */ }; diff --git a/Modules/readline.c b/Modules/readline.c index 0fd4c288ef1..11804c7cc35 100644 --- a/Modules/readline.c +++ b/Modules/readline.c @@ -323,15 +323,19 @@ Insert text into the command line.\ static struct PyMethodDef readline_methods[] = { - {"parse_and_bind", parse_and_bind, 1, doc_parse_and_bind}, + {"parse_and_bind", parse_and_bind, METH_VARARGS, doc_parse_and_bind}, {"get_line_buffer", get_line_buffer, 0, doc_get_line_buffer}, - {"insert_text", insert_text, 1, doc_insert_text}, - {"read_init_file", read_init_file, 1, doc_read_init_file}, - {"read_history_file", read_history_file, 1, doc_read_history_file}, - {"write_history_file", write_history_file, 1, doc_write_history_file}, - {"set_history_length", set_history_length, 1, set_history_length_doc}, - {"get_history_length", get_history_length, 1, get_history_length_doc}, - {"set_completer", set_completer, 1, doc_set_completer}, + {"insert_text", insert_text, METH_VARARGS, doc_insert_text}, + {"read_init_file", read_init_file, METH_VARARGS, doc_read_init_file}, + {"read_history_file", read_history_file, + METH_VARARGS, doc_read_history_file}, + {"write_history_file", write_history_file, + METH_VARARGS, doc_write_history_file}, + {"set_history_length", set_history_length, + METH_VARARGS, set_history_length_doc}, + {"get_history_length", get_history_length, + METH_VARARGS, get_history_length_doc}, + {"set_completer", set_completer, METH_VARARGS, doc_set_completer}, {"get_begidx", get_begidx, 0, doc_get_begidx}, {"get_endidx", get_endidx, 0, doc_get_endidx}, diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 56378acf692..3ff7abd0246 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1344,49 +1344,49 @@ of the socket (flag == 1), or both ends (flag == 2)."; /* List of methods for socket objects */ static PyMethodDef PySocketSock_methods[] = { - {"accept", (PyCFunction)PySocketSock_accept, 1, + {"accept", (PyCFunction)PySocketSock_accept, METH_VARARGS, accept_doc}, - {"bind", (PyCFunction)PySocketSock_bind, 1, + {"bind", (PyCFunction)PySocketSock_bind, METH_VARARGS, bind_doc}, - {"close", (PyCFunction)PySocketSock_close, 1, + {"close", (PyCFunction)PySocketSock_close, METH_VARARGS, close_doc}, - {"connect", (PyCFunction)PySocketSock_connect, 1, + {"connect", (PyCFunction)PySocketSock_connect, METH_VARARGS, connect_doc}, - {"connect_ex", (PyCFunction)PySocketSock_connect_ex, 1, + {"connect_ex", (PyCFunction)PySocketSock_connect_ex, METH_VARARGS, connect_ex_doc}, #ifndef NO_DUP - {"dup", (PyCFunction)PySocketSock_dup, 1, + {"dup", (PyCFunction)PySocketSock_dup, METH_VARARGS, dup_doc}, #endif - {"fileno", (PyCFunction)PySocketSock_fileno, 1, + {"fileno", (PyCFunction)PySocketSock_fileno, METH_VARARGS, fileno_doc}, #ifdef HAVE_GETPEERNAME - {"getpeername", (PyCFunction)PySocketSock_getpeername, 1, + {"getpeername", (PyCFunction)PySocketSock_getpeername, METH_VARARGS, getpeername_doc}, #endif - {"getsockname", (PyCFunction)PySocketSock_getsockname, 1, + {"getsockname", (PyCFunction)PySocketSock_getsockname, METH_VARARGS, getsockname_doc}, - {"getsockopt", (PyCFunction)PySocketSock_getsockopt, 1, + {"getsockopt", (PyCFunction)PySocketSock_getsockopt, METH_VARARGS, getsockopt_doc}, - {"listen", (PyCFunction)PySocketSock_listen, 1, + {"listen", (PyCFunction)PySocketSock_listen, METH_VARARGS, listen_doc}, #ifndef NO_DUP - {"makefile", (PyCFunction)PySocketSock_makefile, 1, + {"makefile", (PyCFunction)PySocketSock_makefile, METH_VARARGS, makefile_doc}, #endif - {"recv", (PyCFunction)PySocketSock_recv, 1, + {"recv", (PyCFunction)PySocketSock_recv, METH_VARARGS, recv_doc}, - {"recvfrom", (PyCFunction)PySocketSock_recvfrom, 1, + {"recvfrom", (PyCFunction)PySocketSock_recvfrom, METH_VARARGS, recvfrom_doc}, - {"send", (PyCFunction)PySocketSock_send, 1, + {"send", (PyCFunction)PySocketSock_send, METH_VARARGS, send_doc}, - {"sendto", (PyCFunction)PySocketSock_sendto, 1, + {"sendto", (PyCFunction)PySocketSock_sendto, METH_VARARGS, sendto_doc}, - {"setblocking", (PyCFunction)PySocketSock_setblocking, 1, + {"setblocking", (PyCFunction)PySocketSock_setblocking, METH_VARARGS, setblocking_doc}, - {"setsockopt", (PyCFunction)PySocketSock_setsockopt, 1, + {"setsockopt", (PyCFunction)PySocketSock_setsockopt, METH_VARARGS, setsockopt_doc}, - {"shutdown", (PyCFunction)PySocketSock_shutdown, 1, + {"shutdown", (PyCFunction)PySocketSock_shutdown, METH_VARARGS, shutdown_doc}, {NULL, NULL} /* sentinel */ }; @@ -2199,24 +2199,39 @@ static PyObject *SSL_SSLread(SSLObject *self, PyObject *args) /* List of functions exported by this module. */ static PyMethodDef PySocket_methods[] = { - {"gethostbyname", PySocket_gethostbyname, 1, gethostbyname_doc}, - {"gethostbyname_ex", PySocket_gethostbyname_ex, 1, ghbn_ex_doc}, - {"gethostbyaddr", PySocket_gethostbyaddr, 1, gethostbyaddr_doc}, - {"gethostname", PySocket_gethostname, 1, gethostname_doc}, - {"getservbyname", PySocket_getservbyname, 1, getservbyname_doc}, - {"getprotobyname", PySocket_getprotobyname, 1,getprotobyname_doc}, - {"socket", PySocket_socket, 1, socket_doc}, + {"gethostbyname", PySocket_gethostbyname, + METH_VARARGS, gethostbyname_doc}, + {"gethostbyname_ex", PySocket_gethostbyname_ex, + METH_VARARGS, ghbn_ex_doc}, + {"gethostbyaddr", PySocket_gethostbyaddr, + METH_VARARGS, gethostbyaddr_doc}, + {"gethostname", PySocket_gethostname, + METH_VARARGS, gethostname_doc}, + {"getservbyname", PySocket_getservbyname, + METH_VARARGS, getservbyname_doc}, + {"getprotobyname", PySocket_getprotobyname, + METH_VARARGS,getprotobyname_doc}, + {"socket", PySocket_socket, + METH_VARARGS, socket_doc}, #ifndef NO_DUP - {"fromfd", PySocket_fromfd, 1, fromfd_doc}, + {"fromfd", PySocket_fromfd, + METH_VARARGS, fromfd_doc}, #endif - {"ntohs", PySocket_ntohs, 1, ntohs_doc}, - {"ntohl", PySocket_ntohl, 1, ntohl_doc}, - {"htons", PySocket_htons, 1, htons_doc}, - {"htonl", PySocket_htonl, 1, htonl_doc}, - {"inet_aton", PySocket_inet_aton, 1, inet_aton_doc}, - {"inet_ntoa", PySocket_inet_ntoa, 1, inet_ntoa_doc}, + {"ntohs", PySocket_ntohs, + METH_VARARGS, ntohs_doc}, + {"ntohl", PySocket_ntohl, + METH_VARARGS, ntohl_doc}, + {"htons", PySocket_htons, + METH_VARARGS, htons_doc}, + {"htonl", PySocket_htonl, + METH_VARARGS, htonl_doc}, + {"inet_aton", PySocket_inet_aton, + METH_VARARGS, inet_aton_doc}, + {"inet_ntoa", PySocket_inet_ntoa, + METH_VARARGS, inet_ntoa_doc}, #ifdef USE_SSL - {"ssl", PySocket_ssl, 1, ssl_doc}, + {"ssl", PySocket_ssl, + METH_VARARGS, ssl_doc}, #endif /* USE_SSL */ {NULL, NULL} /* Sentinel */ }; diff --git a/Modules/soundex.c b/Modules/soundex.c index acb33442211..d230ee1d5fe 100644 --- a/Modules/soundex.c +++ b/Modules/soundex.c @@ -157,10 +157,12 @@ sound_similar(PyObject *self, PyObject *args) */ static PyMethodDef SoundexMethods[] = { - {"sound_similar", sound_similar, 1, soundex_sound_similar__doc__}, - {"get_soundex", get_soundex, 1, soundex_get_soundex__doc__}, + {"sound_similar", sound_similar, + METH_VARARGS, soundex_sound_similar__doc__}, + {"get_soundex", get_soundex, + METH_VARARGS, soundex_get_soundex__doc__}, - {NULL, NULL } /* sentinel */ + {NULL, NULL } /* sentinel */ }; diff --git a/Modules/stropmodule.c b/Modules/stropmodule.c index 0ec9e3dd65c..0353ca555c2 100644 --- a/Modules/stropmodule.c +++ b/Modules/stropmodule.c @@ -1154,26 +1154,40 @@ strop_replace(PyObject *self, PyObject *args) static PyMethodDef strop_methods[] = { - {"atof", strop_atof, 1, atof__doc__}, - {"atoi", strop_atoi, 1, atoi__doc__}, - {"atol", strop_atol, 1, atol__doc__}, + {"atof", strop_atof, + METH_VARARGS, atof__doc__}, + {"atoi", strop_atoi, + METH_VARARGS, atoi__doc__}, + {"atol", strop_atol, + METH_VARARGS, atol__doc__}, {"capitalize", strop_capitalize, 0, capitalize__doc__}, - {"count", strop_count, 1, count__doc__}, - {"expandtabs", strop_expandtabs, 1, expandtabs__doc__}, - {"find", strop_find, 1, find__doc__}, - {"join", strop_joinfields, 1, joinfields__doc__}, - {"joinfields", strop_joinfields, 1, joinfields__doc__}, + {"count", strop_count, + METH_VARARGS, count__doc__}, + {"expandtabs", strop_expandtabs, + METH_VARARGS, expandtabs__doc__}, + {"find", strop_find, + METH_VARARGS, find__doc__}, + {"join", strop_joinfields, + METH_VARARGS, joinfields__doc__}, + {"joinfields", strop_joinfields, + METH_VARARGS, joinfields__doc__}, {"lstrip", strop_lstrip, 0, lstrip__doc__}, {"lower", strop_lower, 0, lower__doc__}, - {"maketrans", strop_maketrans, 1, maketrans__doc__}, - {"replace", strop_replace, 1, replace__doc__}, - {"rfind", strop_rfind, 1, rfind__doc__}, + {"maketrans", strop_maketrans, + METH_VARARGS, maketrans__doc__}, + {"replace", strop_replace, + METH_VARARGS, replace__doc__}, + {"rfind", strop_rfind, + METH_VARARGS, rfind__doc__}, {"rstrip", strop_rstrip, 0, rstrip__doc__}, - {"split", strop_splitfields, 1, splitfields__doc__}, - {"splitfields", strop_splitfields, 1, splitfields__doc__}, + {"split", strop_splitfields, + METH_VARARGS, splitfields__doc__}, + {"splitfields", strop_splitfields, + METH_VARARGS, splitfields__doc__}, {"strip", strop_strip, 0, strip__doc__}, {"swapcase", strop_swapcase, 0, swapcase__doc__}, - {"translate", strop_translate, 1, translate__doc__}, + {"translate", strop_translate, + METH_VARARGS, translate__doc__}, {"upper", strop_upper, 0, upper__doc__}, {NULL, NULL} /* sentinel */ }; diff --git a/Modules/threadmodule.c b/Modules/threadmodule.c index ef73c26fc6a..5d0de4a14dc 100644 --- a/Modules/threadmodule.c +++ b/Modules/threadmodule.c @@ -337,9 +337,11 @@ be relied upon, and the number should be seen purely as a magic cookie.\n\ A thread's identity may be reused for another thread after it exits."; static PyMethodDef thread_methods[] = { - {"start_new_thread", (PyCFunction)thread_PyThread_start_new_thread, 1, + {"start_new_thread", (PyCFunction)thread_PyThread_start_new_thread, + METH_VARARGS, start_new_doc}, - {"start_new", (PyCFunction)thread_PyThread_start_new_thread, 1, + {"start_new", (PyCFunction)thread_PyThread_start_new_thread, + METH_VARARGS, start_new_doc}, {"allocate_lock", (PyCFunction)thread_PyThread_allocate_lock, 0, allocate_doc}, diff --git a/Modules/timemodule.c b/Modules/timemodule.c index db8e163107c..e84a32cd54f 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -498,16 +498,16 @@ static PyMethodDef time_methods[] = { {"sleep", time_sleep, 0, sleep_doc}, {"gmtime", time_gmtime, 0, gmtime_doc}, {"localtime", time_localtime, 0, localtime_doc}, - {"asctime", time_asctime, 1, asctime_doc}, + {"asctime", time_asctime, METH_VARARGS, asctime_doc}, {"ctime", time_ctime, 0, ctime_doc}, #ifdef HAVE_MKTIME - {"mktime", time_mktime, 1, mktime_doc}, + {"mktime", time_mktime, METH_VARARGS, mktime_doc}, #endif #ifdef HAVE_STRFTIME - {"strftime", time_strftime, 1, strftime_doc}, + {"strftime", time_strftime, METH_VARARGS, strftime_doc}, #endif #ifdef HAVE_STRPTIME - {"strptime", time_strptime, 1, strptime_doc}, + {"strptime", time_strptime, METH_VARARGS, strptime_doc}, #endif {NULL, NULL} /* sentinel */ };