Issue 8866: socket.getaddrinfo() should support keyword arguments (original) (raw)

Created on 2010-05-31 22:50 by giampaolo.rodola, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
getaddrinfo.patch giampaolo.rodola,2010-08-14 18:04
Messages (8)
msg106817 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-05-31 22:50
As of now socket.getaddrinfo() only supports positional arguments, so that if I want to, say, specify "flags" argument I'm forced to specify "0" for other missing arguments: >>> socket.getaddrinfo("www.python.org", 0, 0, 0, socket.SOL_TCP) [(2, 1, 6, '', ('82.94.164.162', 0)), (10, 1, 6, '', ('2001:888:2000:d::a2', 0, 0, 0))] >>> >>> socket.getaddrinfo("www.python.org", flags=socket.SOL_TCP) Traceback (most recent call last): File "", line 1, in TypeError: getaddrinfo() takes no keyword arguments >>>
msg106818 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-05-31 22:52
...also, the returning tuples could be named tuples instead.
msg106909 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-06-02 20:08
The patch in attachment implements keyword arguments.
msg106917 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-06-02 21:33
Created issue 8881 to treat the named tuples issue separately.
msg113919 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-08-14 18:04
Updated patch in attachment includes tests and doc update. I decided to rename "socktype" argument in "type", since that's the name adopted all across the socket module API: socket.socket([family[, type[, proto]]]) socket.socket.type socket.socketpair([family[, type[, proto]]]) socket.fromfd(fd, family, type[, proto]) This is safe and doesn't introduce any incompatibility.
msg113933 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-08-14 21:57
-.. function:: getaddrinfo(host, port, family=0, socktype=0, proto=0, flags=0) +.. function:: getaddrinfo(host, port[, family[, type[, proto[, flags]]]]) You should keep using the new documentation convention, that is: .. function:: getaddrinfo(host, port, family=0, type=0, proto=0, flags=0)
msg114125 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-08-17 14:55
Isn't that exactly as it was before? Being now possible to specify single keyword arguments aren't "[" brackets necessary?
msg114129 - (view) Author: Giampaolo Rodola' (giampaolo.rodola) * (Python committer) Date: 2010-08-17 15:31
Committed in r84143 including the doc change as suggested by Antoine.
History
Date User Action Args
2022-04-11 14:57:01 admin set github: 53112
2010-08-17 15:31:26 giampaolo.rodola set status: open -> closedresolution: fixedmessages: +
2010-08-17 14:55:12 giampaolo.rodola set messages: +
2010-08-14 21:57:43 pitrou set messages: +
2010-08-14 18:05:14 giampaolo.rodola set files: - kwargs.patch
2010-08-14 18:04:54 giampaolo.rodola set files: + getaddrinfo.patchmessages: +
2010-06-02 21:33:13 giampaolo.rodola set messages: +
2010-06-02 20:08:17 giampaolo.rodola set files: + kwargs.patchkeywords: + patchmessages: +
2010-05-31 22:52:18 giampaolo.rodola set messages: +
2010-05-31 22:50:11 giampaolo.rodola create