From: Senthil Kumaran Date: Sun, 27 Dec 2009 09:11:09 +0000 (+0000) Subject: Fix for issue5625 - test_urllib2 fails - urlopen error file not on local host. X-Git-Tag: v2.7a2~109 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=13c2ef92f81092a4e46382e52bf586eb6bf512ed;p=thirdparty%2FPython%2Fcpython.git Fix for issue5625 - test_urllib2 fails - urlopen error file not on local host. This is on hosts with multiple ip addresses. --- diff --git a/Lib/urllib2.py b/Lib/urllib2.py index 0f590968985d..87ef9fb57a0e 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -1264,8 +1264,9 @@ class FileHandler(BaseHandler): def get_names(self): if FileHandler.names is None: try: - FileHandler.names = (socket.gethostbyname('localhost'), - socket.gethostbyname(socket.gethostname())) + FileHandler.names = tuple( + socket.gethostbyname_ex('localhost')[2] + + socket.gethostbyname_ex(socket.gethostname())[2]) except socket.gaierror: FileHandler.names = (socket.gethostbyname('localhost'),) return FileHandler.names