[Python-Dev] Adding timeout to socket.py and httplib.py
python-dev at alan.kennedy.name
Thu Mar 22 14:22:00 CET 2007
>> - Explicitly check that the address passed is a tuple of (string, integer)
> In the code, I'll just make "host, port = address", I don't think it
> will be a problem at all. Remember that this function primary use is for
> higher level libraries, and that "address" in socket enviroment is
> always, always, (host, port).
It's rather unfortunate that the tuple needs to be unpacked at all.
Instead, it should be possible to simply pass the address tuple
directly to the socsket.getaddrinfo() function, and let it worry about
the tuple-ness of the address, raising exceptions accordingly.
The socket.getaddrinfo() function, unlike every other python socket
function, takes separate host and port parameters. Which forces every
user of the socket.getaddrinfo function to do the same unnecessary and
potentially error-prone address tuple unpacking.
I have raised a feature request to change this.
 socket.getaddrinfo() should take an address tuple.
More information about the Python-Dev