[issue5625] test_urllib2 fails - urlopen error file not on local host

Zsolt Cserna report at bugs.python.org
Wed Dec 15 15:01:53 CET 2010


Zsolt Cserna <zsolt.cserna at morganstanley.com> added the comment:

The order of the IP addresses doesn't matter as urllib2 is flexible enough to handle all local IP addresses as local (that was the original bug - it handled only one IP returned by gethostbyname which returned a random IP if there were more than one).

So picking up the first IP is ok I think as the order of the IP addresses doesn't matter - urllib2 will handle all of them as local.
See urllib2.FileHandler.get_names().

The problem is that gethostbyname doesn't guarantee that it returns one IP address from the set returned by gethostbyname_ex as gethostbyname looks up the name in /etc/hosts file first (or as configured in NSS).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5625>
_______________________________________


More information about the Python-bugs-list mailing list