[Python-Dev] Adding timeout to socket.py and httplib.py (original) (raw)
Alan Kennedy python-dev at alan.kennedy.name
Thu Mar 22 14:22:00 CET 2007
- Previous message: [Python-Dev] Adding timeout to socket.py and httplib.py
- Next message: [Python-Dev] Adding timeout to socket.py and httplib.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
[Alan]
- Explicitly check that the address passed is a tuple of (string, integer)
[Facundo]
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.
[1685962] socket.getaddrinfo() should take an address tuple.
Regards,
Alan.
- Previous message: [Python-Dev] Adding timeout to socket.py and httplib.py
- Next message: [Python-Dev] Adding timeout to socket.py and httplib.py
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]