[Python-checkins] r77058 - python/trunk/Lib/urllib2.py

senthil.kumaran python-checkins at python.org
Sun Dec 27 10:11:10 CET 2009


Author: senthil.kumaran
Date: Sun Dec 27 10:11:09 2009
New Revision: 77058

Log:
Fix for issue5625 - test_urllib2 fails - urlopen error file not on local host.
This is on hosts with multiple ip addresses.



Modified:
   python/trunk/Lib/urllib2.py

Modified: python/trunk/Lib/urllib2.py
==============================================================================
--- python/trunk/Lib/urllib2.py	(original)
+++ python/trunk/Lib/urllib2.py	Sun Dec 27 10:11:09 2009
@@ -1264,8 +1264,9 @@
     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


More information about the Python-checkins mailing list