[issue31198] getaddrinfo: inconsistent handling of port=None

2017-08-14 Thread Nathaniel Smith

Nathaniel Smith added the comment:

Ugh, apparently this weird behavior is actually mandated by the RFC :-(.

RFC 3493:

   The nodename and servname arguments are either null pointers or
   pointers to null-terminated strings.  One or both of these two
   arguments must be a non-null pointer.

So... never mind!

--
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31198] getaddrinfo: inconsistent handling of port=None

2017-08-14 Thread Nathaniel Smith

Changes by Nathaniel Smith :


--
nosy: +giampaolo.rodola

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue31198] getaddrinfo: inconsistent handling of port=None

2017-08-14 Thread Nathaniel Smith

New submission from Nathaniel Smith:

socket.getaddrinfo accepts None as a port argument, and translates it into 0. 
This is handy, because bind() understands 0 to mean "pick a port for me", and 
if you want bind to pick a port for you and port=None is a slightly more 
obvious way to say that then port=0.

For example:

>>> socket.getaddrinfo("127.0.0.1", None)
[(, , 6, '', ('127.0.0.1', 
0)), (, , 17, '', 
('127.0.0.1', 0)), (, , 0, 
'', ('127.0.0.1', 0))]

socket.getaddrinfo also accepts None as a host name; this is necessary because 
the underlying getaddrinfo(3) call has special handling for host=NULL, and we 
need some way to access it:

>>> socket.getaddrinfo(None, 0)
[(, , 6, '', ('::1', 0, 
0, 0)), (, , 17, '', 
('::1', 0, 0, 0)), (, , 0, 
'', ('::1', 0, 0, 0)), (, , 6, '', ('127.0.0.1', 0)), (, 
, 17, '', ('127.0.0.1', 0)), (, , 0, '', ('127.0.0.1', 0))]

However, even though both of these features are supported separately... if you 
try to use them *together*, then socket.getaddrinfo errors out:

>>> socket.getaddrinfo(None, None)
socket.gaierror: [Errno -2] Name or service not known

I expected that last call to be equivalent to socket.getaddrinfo(None, 0).

--
components: Extension Modules
messages: 300236
nosy: njs
priority: normal
severity: normal
status: open
title: getaddrinfo: inconsistent handling of port=None
versions: Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com