This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author cks
Recipients cks
Date 2013-07-06.23:33:51
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1373153632.08.0.45299629619.issue18391@psf.upfronthosting.co.za>
In-reply-to
Content
socket.fromfd() requires you to supply at least the family and type of
the file descriptor that you are turning into a Python socket object.
However the socket module provides no documented way to determine what
these actually are and there are any number of situations where you may
get handed file descriptors with an indeterminate type. Nor does
providing incorrect family and type values raise an exception from
fromfd(), although if you get the wrong values you may get exceptions
from calling methods on the returned socket (you can also get garbled
and nonsensical results from some methods).

(For instance, in Python 3 calling .getsockname() may raise
UnicodeDecodeError under some circumstances.)

Suggested resolution: socket.fromfd() should always determine the
family and type itself and the arguments for them should become
optional. If they are supplied and they do not match the determined
family and type, fromfd() should probably raise an exception
(although that will break some existing code).

Less appealing resolution: the socket module should provide officially
documented and supported methods for determining the family and type
of a (socket) file descriptor. I think that a new module function to
do this would be the cleanest approach.
History
Date User Action Args
2013-07-06 23:33:52ckssetrecipients: + cks
2013-07-06 23:33:52ckssetmessageid: <1373153632.08.0.45299629619.issue18391@psf.upfronthosting.co.za>
2013-07-06 23:33:52ckslinkissue18391 messages
2013-07-06 23:33:51ckscreate