@@ -643,7 +643,7 @@ BUILD_FUNC_DEF_2(getsockaddrlen,PySocketSockObject *,s, int *,len_ret)
643643 /* More cases here... */
644644
645645 default :
646- PyErr_SetString (PySocket_Error , "getsockaddrarg : bad family" );
646+ PyErr_SetString (PySocket_Error , "getsockaddrlen : bad family" );
647647 return 0 ;
648648
649649 }
@@ -661,7 +661,7 @@ BUILD_FUNC_DEF_2(PySocketSock_accept,PySocketSockObject *,s, PyObject *,args)
661661 PyObject * addr = NULL ;
662662 PyObject * res = NULL ;
663663
664- if (!PyArg_NoArgs (args ))
664+ if (!PyArg_ParseTuple (args , ":accept" ))
665665 return NULL ;
666666 if (!getsockaddrlen (s , & addrlen ))
667667 return NULL ;
@@ -710,7 +710,7 @@ BUILD_FUNC_DEF_2(PySocketSock_setblocking,PySocketSockObject*,s,PyObject*,args)
710710#ifndef MS_WINDOWS
711711 int delay_flag ;
712712#endif
713- if (!PyArg_Parse (args , "i" , & block ))
713+ if (!PyArg_ParseTuple (args , "i:setblocking " , & block ))
714714 return NULL ;
715715 Py_BEGIN_ALLOW_THREADS
716716#ifdef __BEOS__
@@ -763,14 +763,15 @@ BUILD_FUNC_DEF_2(PySocketSock_setsockopt,PySocketSockObject *,s, PyObject *,args
763763 int buflen ;
764764 int flag ;
765765
766- if (PyArg_Parse (args , "(iii)" , & level , & optname , & flag )) {
766+ if (PyArg_ParseTuple (args , "iii:setsockopt" ,
767+ & level , & optname , & flag )) {
767768 buf = (char * ) & flag ;
768769 buflen = sizeof flag ;
769770 }
770771 else {
771772 PyErr_Clear ();
772- if (!PyArg_Parse (args , "( iis#)" , & level , & optname ,
773- & buf , & buflen ))
773+ if (!PyArg_ParseTuple (args , "iis#:setsockopt" ,
774+ & level , & optname , & buf , & buflen ))
774775 return NULL ;
775776 }
776777 res = setsockopt (s -> sock_fd , level , optname , (ANY * )buf , buflen );
@@ -807,7 +808,8 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockopt,PySocketSockObject *,s, PyObject *,args
807808 return NULL ;
808809#else
809810
810- if (!PyArg_ParseTuple (args , "ii|i" , & level , & optname , & buflen ))
811+ if (!PyArg_ParseTuple (args , "ii|i:getsockopt" ,
812+ & level , & optname , & buflen ))
811813 return NULL ;
812814
813815 if (buflen == 0 ) {
@@ -854,7 +856,10 @@ BUILD_FUNC_DEF_2(PySocketSock_bind,PySocketSockObject *,s, PyObject *,args)
854856 struct sockaddr * addr ;
855857 int addrlen ;
856858 int res ;
857- if (!getsockaddrarg (s , args , & addr , & addrlen ))
859+ PyObject * addro ;
860+ if (!PyArg_ParseTuple (args , "O:bind" , & addro ))
861+ return NULL ;
862+ if (!getsockaddrarg (s , addro , & addr , & addrlen ))
858863 return NULL ;
859864 Py_BEGIN_ALLOW_THREADS
860865 res = bind (s -> sock_fd , addr , addrlen );
@@ -879,7 +884,7 @@ pair (host, port); the host must refer to the local host.";
879884static PyObject *
880885BUILD_FUNC_DEF_2 (PySocketSock_close ,PySocketSockObject * ,s , PyObject * ,args )
881886{
882- if (!PyArg_NoArgs (args ))
887+ if (!PyArg_ParseTuple (args , ":close" ))
883888 return NULL ;
884889 if (s -> sock_fd != -1 ) {
885890 Py_BEGIN_ALLOW_THREADS
@@ -905,7 +910,10 @@ BUILD_FUNC_DEF_2(PySocketSock_connect,PySocketSockObject *,s, PyObject *,args)
905910 struct sockaddr * addr ;
906911 int addrlen ;
907912 int res ;
908- if (!getsockaddrarg (s , args , & addr , & addrlen ))
913+ PyObject * addro ;
914+ if (!PyArg_ParseTuple (args , "O:connect" , & addro ))
915+ return NULL ;
916+ if (!getsockaddrarg (s , addro , & addr , & addrlen ))
909917 return NULL ;
910918 Py_BEGIN_ALLOW_THREADS
911919 res = connect (s -> sock_fd , addr , addrlen );
@@ -931,7 +939,10 @@ BUILD_FUNC_DEF_2(PySocketSock_connect_ex,PySocketSockObject *,s, PyObject *,args
931939 struct sockaddr * addr ;
932940 int addrlen ;
933941 int res ;
934- if (!getsockaddrarg (s , args , & addr , & addrlen ))
942+ PyObject * addro ;
943+ if (!PyArg_ParseTuple (args , "O:connect_ex" , & addro ))
944+ return NULL ;
945+ if (!getsockaddrarg (s , addro , & addr , & addrlen ))
935946 return NULL ;
936947 Py_BEGIN_ALLOW_THREADS
937948 res = connect (s -> sock_fd , addr , addrlen );
@@ -953,7 +964,7 @@ instead of raising an exception when an error occurs.";
953964static PyObject *
954965BUILD_FUNC_DEF_2 (PySocketSock_fileno ,PySocketSockObject * ,s , PyObject * ,args )
955966{
956- if (!PyArg_NoArgs (args ))
967+ if (!PyArg_ParseTuple (args , ":fileno" ))
957968 return NULL ;
958969 return PyInt_FromLong ((long ) s -> sock_fd );
959970}
@@ -972,7 +983,7 @@ BUILD_FUNC_DEF_2(PySocketSock_dup,PySocketSockObject *,s, PyObject *,args)
972983{
973984 int newfd ;
974985 PyObject * sock ;
975- if (!PyArg_NoArgs (args ))
986+ if (!PyArg_ParseTuple (args , ":dup" ))
976987 return NULL ;
977988 newfd = dup (s -> sock_fd );
978989 if (newfd < 0 )
@@ -1001,7 +1012,7 @@ BUILD_FUNC_DEF_2(PySocketSock_getsockname,PySocketSockObject *,s, PyObject *,arg
10011012{
10021013 char addrbuf [256 ];
10031014 int addrlen , res ;
1004- if (!PyArg_NoArgs (args ))
1015+ if (!PyArg_ParseTuple (args , ":getsockname" ))
10051016 return NULL ;
10061017 if (!getsockaddrlen (s , & addrlen ))
10071018 return NULL ;
@@ -1029,7 +1040,7 @@ BUILD_FUNC_DEF_2(PySocketSock_getpeername,PySocketSockObject *,s, PyObject *,arg
10291040{
10301041 char addrbuf [256 ];
10311042 int addrlen , res ;
1032- if (!PyArg_NoArgs (args ))
1043+ if (!PyArg_ParseTuple (args , ": getpeername " ))
10331044 return NULL ;
10341045 if (!getsockaddrlen (s , & addrlen ))
10351046 return NULL ;
@@ -1057,7 +1068,7 @@ BUILD_FUNC_DEF_2(PySocketSock_listen,PySocketSockObject *,s, PyObject *,args)
10571068{
10581069 int backlog ;
10591070 int res ;
1060- if (!PyArg_Parse (args , "i" , & backlog ))
1071+ if (!PyArg_ParseTuple (args , "i:listen " , & backlog ))
10611072 return NULL ;
10621073 Py_BEGIN_ALLOW_THREADS
10631074 if (backlog < 1 )
@@ -1245,9 +1256,10 @@ BUILD_FUNC_DEF_2(PySocketSock_sendto,PySocketSockObject *,s, PyObject *,args)
12451256 struct sockaddr * addr ;
12461257 int addrlen , len , n , flags ;
12471258 flags = 0 ;
1248- if (!PyArg_Parse (args , "( s#O) " , & buf , & len , & addro )) {
1259+ if (!PyArg_ParseTuple (args , "s#O:sendto " , & buf , & len , & addro )) {
12491260 PyErr_Clear ();
1250- if (!PyArg_Parse (args , "(s#iO)" , & buf , & len , & flags , & addro ))
1261+ if (!PyArg_ParseTuple (args , "s#iO:sendto" ,
1262+ & buf , & len , & flags , & addro ))
12511263 return NULL ;
12521264 }
12531265 if (!getsockaddrarg (s , addro , & addr , & addrlen ))
@@ -1274,7 +1286,7 @@ BUILD_FUNC_DEF_2(PySocketSock_shutdown,PySocketSockObject *,s, PyObject *,args)
12741286{
12751287 int how ;
12761288 int res ;
1277- if (!PyArg_Parse (args , "i" , & how ))
1289+ if (!PyArg_ParseTuple (args , "i:shutdown " , & how ))
12781290 return NULL ;
12791291 Py_BEGIN_ALLOW_THREADS
12801292 res = shutdown (s -> sock_fd , how );
@@ -1295,31 +1307,31 @@ of the socket (flag == 1), or both ends (flag == 2).";
12951307/* List of methods for socket objects */
12961308
12971309static PyMethodDef PySocketSock_methods [] = {
1298- {"accept" , (PyCFunction )PySocketSock_accept , 0 ,
1310+ {"accept" , (PyCFunction )PySocketSock_accept , 1 ,
12991311 accept_doc },
1300- {"bind" , (PyCFunction )PySocketSock_bind , 0 ,
1312+ {"bind" , (PyCFunction )PySocketSock_bind , 1 ,
13011313 bind_doc },
1302- {"close" , (PyCFunction )PySocketSock_close , 0 ,
1314+ {"close" , (PyCFunction )PySocketSock_close , 1 ,
13031315 close_doc },
1304- {"connect" , (PyCFunction )PySocketSock_connect , 0 ,
1316+ {"connect" , (PyCFunction )PySocketSock_connect , 1 ,
13051317 connect_doc },
1306- {"connect_ex" , (PyCFunction )PySocketSock_connect_ex , 0 ,
1318+ {"connect_ex" , (PyCFunction )PySocketSock_connect_ex , 1 ,
13071319 connect_ex_doc },
13081320#ifndef NO_DUP
1309- {"dup" , (PyCFunction )PySocketSock_dup , 0 ,
1321+ {"dup" , (PyCFunction )PySocketSock_dup , 1 ,
13101322 dup_doc },
13111323#endif
1312- {"fileno" , (PyCFunction )PySocketSock_fileno , 0 ,
1324+ {"fileno" , (PyCFunction )PySocketSock_fileno , 1 ,
13131325 fileno_doc },
13141326#ifdef HAVE_GETPEERNAME
1315- {"getpeername" , (PyCFunction )PySocketSock_getpeername , 0 ,
1327+ {"getpeername" , (PyCFunction )PySocketSock_getpeername , 1 ,
13161328 getpeername_doc },
13171329#endif
1318- {"getsockname" , (PyCFunction )PySocketSock_getsockname , 0 ,
1330+ {"getsockname" , (PyCFunction )PySocketSock_getsockname , 1 ,
13191331 getsockname_doc },
13201332 {"getsockopt" , (PyCFunction )PySocketSock_getsockopt , 1 ,
13211333 getsockopt_doc },
1322- {"listen" , (PyCFunction )PySocketSock_listen , 0 ,
1334+ {"listen" , (PyCFunction )PySocketSock_listen , 1 ,
13231335 listen_doc },
13241336#ifndef NO_DUP
13251337 {"makefile" , (PyCFunction )PySocketSock_makefile , 1 ,
@@ -1331,13 +1343,13 @@ static PyMethodDef PySocketSock_methods[] = {
13311343 recvfrom_doc },
13321344 {"send" , (PyCFunction )PySocketSock_send , 1 ,
13331345 send_doc },
1334- {"sendto" , (PyCFunction )PySocketSock_sendto , 0 ,
1346+ {"sendto" , (PyCFunction )PySocketSock_sendto , 1 ,
13351347 sendto_doc },
1336- {"setblocking" , (PyCFunction )PySocketSock_setblocking , 0 ,
1348+ {"setblocking" , (PyCFunction )PySocketSock_setblocking , 1 ,
13371349 setblocking_doc },
1338- {"setsockopt" , (PyCFunction )PySocketSock_setsockopt , 0 ,
1350+ {"setsockopt" , (PyCFunction )PySocketSock_setsockopt , 1 ,
13391351 setsockopt_doc },
1340- {"shutdown" , (PyCFunction )PySocketSock_shutdown , 0 ,
1352+ {"shutdown" , (PyCFunction )PySocketSock_shutdown , 1 ,
13411353 shutdown_doc },
13421354 {NULL , NULL } /* sentinel */
13431355};
@@ -1402,7 +1414,7 @@ BUILD_FUNC_DEF_2(PySocket_gethostname,PyObject *,self, PyObject *,args)
14021414{
14031415 char buf [1024 ];
14041416 int res ;
1405- if (!PyArg_NoArgs (args ))
1417+ if (!PyArg_ParseTuple (args , ":gethostname" ))
14061418 return NULL ;
14071419 Py_BEGIN_ALLOW_THREADS
14081420 res = gethostname (buf , (int ) sizeof buf - 1 );
@@ -1427,7 +1439,7 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyname,PyObject *,self, PyObject *,args)
14271439{
14281440 char * name ;
14291441 struct sockaddr_in addrbuf ;
1430- if (!PyArg_Parse (args , "s" , & name ))
1442+ if (!PyArg_ParseTuple (args , "s:gethostbyname " , & name ))
14311443 return NULL ;
14321444 if (setipaddr (name , & addrbuf ) < 0 )
14331445 return NULL ;
@@ -1518,7 +1530,7 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyname_ex,PyObject *,self, PyObject *,args)
15181530 int result ;
15191531#endif
15201532#endif /* HAVE_GETHOSTBYNAME_R */
1521- if (!PyArg_Parse (args , "s" , & name ))
1533+ if (!PyArg_ParseTuple (args , "s:gethostbyname_ex " , & name ))
15221534 return NULL ;
15231535 if (setipaddr (name , & addr ) < 0 )
15241536 return NULL ;
@@ -1578,7 +1590,7 @@ BUILD_FUNC_DEF_2(PySocket_gethostbyaddr,PyObject *,self, PyObject *, args)
15781590#endif
15791591#endif /* HAVE_GETHOSTBYNAME_R */
15801592
1581- if (!PyArg_Parse (args , "s" , & ip_num ))
1593+ if (!PyArg_ParseTuple (args , "s:gethostbyaddr " , & ip_num ))
15821594 return NULL ;
15831595 if (setipaddr (ip_num , & addr ) < 0 )
15841596 return NULL ;
@@ -1634,7 +1646,7 @@ BUILD_FUNC_DEF_2(PySocket_getservbyname,PyObject *,self, PyObject *,args)
16341646{
16351647 char * name , * proto ;
16361648 struct servent * sp ;
1637- if (!PyArg_Parse (args , "(ss) " , & name , & proto ))
1649+ if (!PyArg_ParseTuple (args , "ss:getservbyname " , & name , & proto ))
16381650 return NULL ;
16391651 Py_BEGIN_ALLOW_THREADS
16401652 sp = getservbyname (name , proto );
@@ -1668,7 +1680,7 @@ BUILD_FUNC_DEF_2(PySocket_getprotobyname,PyObject *,self, PyObject *,args)
16681680 PyErr_SetString ( PySocket_Error , "getprotobyname not supported" );
16691681 return NULL ;
16701682#else
1671- if (!PyArg_Parse (args , "s" , & name ))
1683+ if (!PyArg_ParseTuple (args , "s:getprotobyname " , & name ))
16721684 return NULL ;
16731685 Py_BEGIN_ALLOW_THREADS
16741686 sp = getprotobyname (name );
@@ -1747,7 +1759,8 @@ BUILD_FUNC_DEF_2(PySocket_fromfd,PyObject *,self, PyObject *,args)
17471759{
17481760 PySocketSockObject * s ;
17491761 int fd , family , type , proto = 0 ;
1750- if (!PyArg_ParseTuple (args , "iii|i:fromfd" , & fd , & family , & type , & proto ))
1762+ if (!PyArg_ParseTuple (args , "iii|i:fromfd" ,
1763+ & fd , & family , & type , & proto ))
17511764 return NULL ;
17521765 /* Dup the fd so it and the socket can be closed independently */
17531766 fd = dup (fd );
@@ -1776,7 +1789,7 @@ BUILD_FUNC_DEF_2(PySocket_ntohs, PyObject *, self, PyObject *, args)
17761789{
17771790 int x1 , x2 ;
17781791
1779- if (!PyArg_Parse (args , "i" , & x1 )) {
1792+ if (!PyArg_ParseTuple (args , "i:ntohs " , & x1 )) {
17801793 return NULL ;
17811794 }
17821795 x2 = (int )ntohs ((short )x1 );
@@ -1794,7 +1807,7 @@ BUILD_FUNC_DEF_2(PySocket_ntohl, PyObject *, self, PyObject *, args)
17941807{
17951808 int x1 , x2 ;
17961809
1797- if (!PyArg_Parse (args , "i" , & x1 )) {
1810+ if (!PyArg_ParseTuple (args , "i:ntohl " , & x1 )) {
17981811 return NULL ;
17991812 }
18001813 x2 = ntohl (x1 );
@@ -1812,7 +1825,7 @@ BUILD_FUNC_DEF_2(PySocket_htons, PyObject *, self, PyObject *, args)
18121825{
18131826 int x1 , x2 ;
18141827
1815- if (!PyArg_Parse (args , "i" , & x1 )) {
1828+ if (!PyArg_ParseTuple (args , "i:htons " , & x1 )) {
18161829 return NULL ;
18171830 }
18181831 x2 = (int )htons ((short )x1 );
@@ -1830,7 +1843,7 @@ BUILD_FUNC_DEF_2(PySocket_htonl, PyObject *, self, PyObject *, args)
18301843{
18311844 int x1 , x2 ;
18321845
1833- if (!PyArg_Parse (args , "i" , & x1 )) {
1846+ if (!PyArg_ParseTuple (args , "i:htonl " , & x1 )) {
18341847 return NULL ;
18351848 }
18361849 x2 = htonl (x1 );
@@ -1866,7 +1879,7 @@ BUILD_FUNC_DEF_2(PySocket_inet_aton, PyObject *, self, PyObject *, args)
18661879 char * ip_addr ;
18671880 long packed_addr ;
18681881
1869- if (!PyArg_Parse (args , "s" , & ip_addr )) {
1882+ if (!PyArg_ParseTuple (args , "s:inet_aton " , & ip_addr )) {
18701883 return NULL ;
18711884 }
18721885#ifdef macintosh
@@ -1897,7 +1910,7 @@ BUILD_FUNC_DEF_2(PySocket_inet_ntoa, PyObject *, self, PyObject *, args)
18971910 int addr_len ;
18981911 struct in_addr packed_addr ;
18991912
1900- if (!PyArg_Parse (args , "s#" , & packed_str , & addr_len )) {
1913+ if (!PyArg_ParseTuple (args , "s#:inet_ntoa " , & packed_str , & addr_len )) {
19011914 return NULL ;
19021915 }
19031916
@@ -2151,22 +2164,22 @@ static PyObject *SSL_SSLread(SSLObject *self, PyObject *args)
21512164/* List of functions exported by this module. */
21522165
21532166static PyMethodDef PySocket_methods [] = {
2154- {"gethostbyname" , PySocket_gethostbyname , 0 , gethostbyname_doc },
2155- {"gethostbyname_ex" , PySocket_gethostbyname_ex , 0 , ghbn_ex_doc },
2156- {"gethostbyaddr" , PySocket_gethostbyaddr , 0 , gethostbyaddr_doc },
2157- {"gethostname" , PySocket_gethostname , 0 , gethostname_doc },
2158- {"getservbyname" , PySocket_getservbyname , 0 , getservbyname_doc },
2159- {"getprotobyname" , PySocket_getprotobyname , 0 ,getprotobyname_doc },
2167+ {"gethostbyname" , PySocket_gethostbyname , 1 , gethostbyname_doc },
2168+ {"gethostbyname_ex" , PySocket_gethostbyname_ex , 1 , ghbn_ex_doc },
2169+ {"gethostbyaddr" , PySocket_gethostbyaddr , 1 , gethostbyaddr_doc },
2170+ {"gethostname" , PySocket_gethostname , 1 , gethostname_doc },
2171+ {"getservbyname" , PySocket_getservbyname , 1 , getservbyname_doc },
2172+ {"getprotobyname" , PySocket_getprotobyname , 1 ,getprotobyname_doc },
21602173 {"socket" , PySocket_socket , 1 , socket_doc },
21612174#ifndef NO_DUP
21622175 {"fromfd" , PySocket_fromfd , 1 , fromfd_doc },
21632176#endif
2164- {"ntohs" , PySocket_ntohs , 0 , ntohs_doc },
2165- {"ntohl" , PySocket_ntohl , 0 , ntohl_doc },
2166- {"htons" , PySocket_htons , 0 , htons_doc },
2167- {"htonl" , PySocket_htonl , 0 , htonl_doc },
2168- {"inet_aton" , PySocket_inet_aton , 0 , inet_aton_doc },
2169- {"inet_ntoa" , PySocket_inet_ntoa , 0 , inet_ntoa_doc },
2177+ {"ntohs" , PySocket_ntohs , 1 , ntohs_doc },
2178+ {"ntohl" , PySocket_ntohl , 1 , ntohl_doc },
2179+ {"htons" , PySocket_htons , 1 , htons_doc },
2180+ {"htonl" , PySocket_htonl , 1 , htonl_doc },
2181+ {"inet_aton" , PySocket_inet_aton , 1 , inet_aton_doc },
2182+ {"inet_ntoa" , PySocket_inet_ntoa , 1 , inet_ntoa_doc },
21702183#ifdef USE_SSL
21712184 {"ssl" , PySocket_ssl , 1 , ssl_doc },
21722185#endif /* USE_SSL */
0 commit comments