summaryrefslogtreecommitdiffstats
path: root/Modules/socketmodule.c
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2010-08-09 20:39:54 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2010-08-09 20:39:54 (GMT)
commit6e451df800af66eefe68ea15938bd65029af06c5 (patch)
tree3a94bf3c48a965f464f1f112d384076103a4676a /Modules/socketmodule.c
parent30e86a47676d2175901af29445aec5bd7967ef76 (diff)
downloadcpython-6e451df800af66eefe68ea15938bd65029af06c5.zip
cpython-6e451df800af66eefe68ea15938bd65029af06c5.tar.gz
cpython-6e451df800af66eefe68ea15938bd65029af06c5.tar.bz2
Followup to r83869 and issue #8524: rename socket.forget() to socket.detach()
and make it return the file descriptor.
Diffstat (limited to 'Modules/socketmodule.c')
-rw-r--r--Modules/socketmodule.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c
index fc671e0..b1a616e 100644
--- a/Modules/socketmodule.c
+++ b/Modules/socketmodule.c
@@ -1870,19 +1870,19 @@ PyDoc_STRVAR(close_doc,
Close the socket. It cannot be used after this call.");
static PyObject *
-sock_forget(PySocketSockObject *s)
+sock_detach(PySocketSockObject *s)
{
+ SOCKET_T fd = s->sock_fd;
s->sock_fd = -1;
- Py_INCREF(Py_None);
- return Py_None;
+ return PyLong_FromSocket_t(fd);
}
-PyDoc_STRVAR(forget_doc,
-"forget()\n\
+PyDoc_STRVAR(detach_doc,
+"detach()\n\
\n\
Close the socket object without closing the underlying file descriptor.\
The object cannot be used after this call, but the file descriptor\
-can be reused for other purposes.");
+can be reused for other purposes. The file descriptor is returned.");
static int
internal_connect(PySocketSockObject *s, struct sockaddr *addr, int addrlen,
@@ -2772,10 +2772,10 @@ static PyMethodDef sock_methods[] = {
connect_doc},
{"connect_ex", (PyCFunction)sock_connect_ex, METH_O,
connect_ex_doc},
+ {"detach", (PyCFunction)sock_detach, METH_NOARGS,
+ detach_doc},
{"fileno", (PyCFunction)sock_fileno, METH_NOARGS,
fileno_doc},
- {"forget", (PyCFunction)sock_forget, METH_NOARGS,
- forget_doc},
#ifdef HAVE_GETPEERNAME
{"getpeername", (PyCFunction)sock_getpeername,
METH_NOARGS, getpeername_doc},