summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c36
1 files changed, 21 insertions, 15 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index 6502ced..b10268e 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -45,15 +45,12 @@ Module interface:
- a UNIX domain socket address is a string specifying the pathname
Socket methods:
-(NB: an argument list of the form (sockaddr...) means that multiple
-arguments are treated the same as a single tuple argument, for backwards
-compatibility. This is deprecated, and will be removed in future versions.)
- s.accept() --> new socket object, sockaddr
-- s.bind(sockaddr...) --> None
+- s.bind(sockaddr) --> None
- s.close() --> None
-- s.connect(sockaddr...) --> None
-- s.connect_ex(sockaddr...) --> 0 or errno (handy for e.g. async connect)
+- s.connect(sockaddr) --> None
+- s.connect_ex(sockaddr) --> 0 or errno (handy for e.g. async connect)
- s.fileno() --> file descriptor
- s.dup() --> same as socket.fromfd(os.dup(s.fileno(), ...)
- s.getpeername() --> sockaddr
@@ -856,7 +853,7 @@ If a nonzero buffersize argument is given, the return value is a\n\
string of that length; otherwise it is an integer.";
-/* s.bind(sockaddr...) method */
+/* s.bind(sockaddr) method */
static PyObject *
BUILD_FUNC_DEF_2(PySocketSock_bind,PySocketSockObject *,s, PyObject *,args)
@@ -864,7 +861,10 @@ BUILD_FUNC_DEF_2(PySocketSock_bind,PySocketSockObject *,s, PyObject *,args)
struct sockaddr *addr;
int addrlen;
int res;
- if (!getsockaddrarg(s, args, &addr, &addrlen))
+ PyObject *addro;
+ if (!PyArg_ParseTuple(args, "O:bind", &addro))
+ return NULL;
+ if (!getsockaddrarg(s, addro, &addr, &addrlen))
return NULL;
Py_BEGIN_ALLOW_THREADS
res = bind(s->sock_fd, addr, addrlen);
@@ -907,7 +907,7 @@ static char close_doc[] =
Close the socket. It cannot be used after this call.";
-/* s.connect(sockaddr...) method */
+/* s.connect(sockaddr) method */
static PyObject *
BUILD_FUNC_DEF_2(PySocketSock_connect,PySocketSockObject *,s, PyObject *,args)
@@ -915,7 +915,10 @@ BUILD_FUNC_DEF_2(PySocketSock_connect,PySocketSockObject *,s, PyObject *,args)
struct sockaddr *addr;
int addrlen;
int res;
- if (!getsockaddrarg(s, args, &addr, &addrlen))
+ PyObject *addro;
+ if (!PyArg_ParseTuple(args, "O:connect", &addro))
+ return NULL;
+ if (!getsockaddrarg(s, addro, &addr, &addrlen))
return NULL;
Py_BEGIN_ALLOW_THREADS
res = connect(s->sock_fd, addr, addrlen);
@@ -933,7 +936,7 @@ Connect the socket to a remote address. For IP sockets, the address\n\
is a pair (host, port).";
-/* s.connect_ex(sockaddr...) method */
+/* s.connect_ex(sockaddr) method */
static PyObject *
BUILD_FUNC_DEF_2(PySocketSock_connect_ex,PySocketSockObject *,s, PyObject *,args)
@@ -941,7 +944,10 @@ BUILD_FUNC_DEF_2(PySocketSock_connect_ex,PySocketSockObject *,s, PyObject *,args
struct sockaddr *addr;
int addrlen;
int res;
- if (!getsockaddrarg(s, args, &addr, &addrlen))
+ PyObject *addro;
+ if (!PyArg_ParseTuple(args, "O:connect_ex", &addro))
+ return NULL;
+ if (!getsockaddrarg(s, addro, &addr, &addrlen))
return NULL;
Py_BEGIN_ALLOW_THREADS
res = connect(s->sock_fd, addr, addrlen);
@@ -1321,13 +1327,13 @@ of the socket (flag == 1), or both ends (flag == 2).";
static PyMethodDef PySocketSock_methods[] = {
{"accept", (PyCFunction)PySocketSock_accept, 1,
accept_doc},
- {"bind", (PyCFunction)PySocketSock_bind, 0,
+ {"bind", (PyCFunction)PySocketSock_bind, 1,
bind_doc},
{"close", (PyCFunction)PySocketSock_close, 1,
close_doc},
- {"connect", (PyCFunction)PySocketSock_connect, 0,
+ {"connect", (PyCFunction)PySocketSock_connect, 1,
connect_doc},
- {"connect_ex", (PyCFunction)PySocketSock_connect_ex, 0,
+ {"connect_ex", (PyCFunction)PySocketSock_connect_ex, 1,
connect_ex_doc},
#ifndef NO_DUP
{"dup", (PyCFunction)PySocketSock_dup, 1,