From a7993a7f82a781f0310b9fac645d183b04f94ed4 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sat, 1 Apr 2006 07:33:22 +0000 Subject: [PATCH] Bug #1460564: document that socket.fromfd() duplicates the given file descriptor. (backport from rev. 43523) --- Doc/lib/libsocket.tex | 9 +++++---- Modules/socketmodule.c | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/Doc/lib/libsocket.tex b/Doc/lib/libsocket.tex index e3d9a92a85b4..8e0d5d3615f0 100644 --- a/Doc/lib/libsocket.tex +++ b/Doc/lib/libsocket.tex @@ -314,10 +314,11 @@ Availability: \UNIX. \versionadded{2.4} \end{funcdesc} \begin{funcdesc}{fromfd}{fd, family, type\optional{, proto}} -Build a socket object from an existing file descriptor (an integer as -returned by a file object's \method{fileno()} method). Address family, -socket type and protocol number are as for the \function{socket()} function -above. The file descriptor should refer to a socket, but this is not +Duplicate the file descriptor \var{fd} (an integer as returned by a file +object's \method{fileno()} method) and build a socket object from the +result. Address family, socket type and protocol number are as for the +\function{socket()} function above. +The file descriptor should refer to a socket, but this is not checked --- subsequent operations on the object may fail if the file descriptor is invalid. This function is rarely needed, but can be used to get or set socket options on a socket passed to a program as diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index a5d2bf3c437b..5a148666dc00 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -3113,7 +3113,8 @@ socket_fromfd(PyObject *self, PyObject *args) PyDoc_STRVAR(fromfd_doc, "fromfd(fd, family, type[, proto]) -> socket object\n\ \n\ -Create a socket object from the given file descriptor.\n\ +Create a socket object from a duplicate of the given\n\ +file descriptor.\n\ The remaining arguments are the same as for socket()."); #endif /* NO_DUP */ -- 2.47.3