Getaddrinfo with <broadcast> and null string

Hi,

I was looking at the sockets interface, and the docs state:

For IPv4 addresses, two special forms are accepted instead of a host address: '' represents INADDR_ANY, which is used to bind to all interfaces, and the string '<broadcast>' represents INADDR_BROADCAST. This behavior is not compatible with IPv6, therefore, you may want to avoid these if you intend to support IPv6 with your Python programs.

yet I get this error:

print(socket.getaddrinfo('<broadcast>',9,family=socket.AF_INET))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python3.10/socket.py", line 955, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno -2] Name or service not known

and the same for a hostname of ''.

Is this intended functionality?

I don’t think those special forms work with getaddrinfo; they’re meant for direct use in either bind or connect.

But gethostbyname() works with ”<broadcast>”

It’s a minor point, but I’m trying to submit a patch to uvloop which is supposed to mimic the default asyncio implementation, so I’m trying to find out if it is an oversight, documentation issue, or intended functionality.

Oh interesting, I didn’t know that! Then yes, it might be an oversight that getaddrinfo doesn’t recognize them.

Should I report it as an issue?