]> granicus.if.org Git - python/commitdiff
Fix for issue5625 - test_urllib2 fails - urlopen error file not on local host.
authorSenthil Kumaran <orsenthil@gmail.com>
Sun, 27 Dec 2009 09:11:09 +0000 (09:11 +0000)
committerSenthil Kumaran <orsenthil@gmail.com>
Sun, 27 Dec 2009 09:11:09 +0000 (09:11 +0000)
This is on hosts with multiple ip addresses.

Lib/urllib2.py

index 0f590968985d7b08144d7b0e74de687e9be05c66..87ef9fb57a0e1fe2b895828acae3d1e51ed59c6d 100644 (file)
@@ -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