Fix exceptions if python is built without ipv6 support.

See:
http://bugs.python.org/issue16208
http://bugs.python.org/issue7735
I tried with both 2.7.8 and 3.3.5 on my desktop (ipv6 enabled): they're 'str' with both; 

however, on the board where i disabled ipv6, I get this:

Python 2.7.8 (default, Oct 24 2014, 15:09:35) 
[GCC 4.8.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> socket.has_ipv6
False
>>> socket.getaddrinfo("localhost", 0, 0, 0, socket.SOL_TCP)
[(10, 1, 6, '', (10, '\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00')), (2, 1, 6, '', ('127.0.0.1', 0))]


so here, host[4][0] is int, causing the exception.

it can be fixed on my side by removing the '::1 localhost' line in /etc/hosts though, so that python doesn't even try to look that up, but i thought it would be useful to make the code more robust too.