This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

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
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 2022-04-11 14:56 by admin. 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, '', ('', 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
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
Date User Action Args
2022-04-11 14:56:30adminsetgithub: 46250
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