classification
Title: IPv6 compiled getaddrinfo returns IPv6 address even if the system does not support IPv6
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.4
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: douglas, loewis
Priority: normal Keywords:

Created on 2008-01-28 21:51 by douglas, last changed 2008-01-28 22:28 by douglas. This issue is now closed.

Messages (4)
msg61799 - (view) Author: Douglas Mayle (douglas) * Date: 2008-01-28 21:51
The following code calls getadddrinfo and returns invalid addresses
(IPv6 addresses) when Python has been compiled with IPv6 support and the
system kernel does not support IPv6.

import socket
for res in socket.getaddrinfo("localhost", "80", 0, socket.SOCK_STREAM):
    print "%r" % (res,)

(2, 1, 6, '', ('127.0.0.1', 80))
(10, 1, 6, '', ('::1', 80, 0, 0))
msg61801 - (view) Author: Douglas Mayle (douglas) * Date: 2008-01-28 21:57
Please close this as invalid, the system C library returns the same
response...
msg61804 - (view) Author: Martin v. Löwis (loewis) * (Python committer) Date: 2008-01-28 22:11
My guess is that the C library returns it because /etc/hosts says so.
The convention is that /etc/hosts should call ::1 ip6-localhost (and
ip6-loopback) instead.
msg61805 - (view) Author: Douglas Mayle (douglas) * Date: 2008-01-28 22:28
Martin's hypothesis is confirmed, removing ::1 from /etc/hosts removes
the response
History
Date User Action Args
2008-01-28 22:28:52douglassetmessages: + msg61805
2008-01-28 22:11:51loewissetstatus: open -> closed
resolution: not a bug
messages: + msg61804
nosy: + loewis
2008-01-28 21:57:43douglassetmessages: + msg61801
2008-01-28 21:51:14douglascreate