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

georg.brandl python-checkins at python.org
Sun Apr 2 22:37:17 CEST 2006


Author: georg.brandl
Date: Sun Apr  2 22:37:17 2006
New Revision: 43552

Modified:
   python/trunk/Lib/urllib2.py
Log:
bug #1462706: guard against host not having FQDN hostname



Modified: python/trunk/Lib/urllib2.py
==============================================================================
--- python/trunk/Lib/urllib2.py	(original)
+++ python/trunk/Lib/urllib2.py	Sun Apr  2 22:37:17 2006
@@ -1130,8 +1130,11 @@
     names = None
     def get_names(self):
         if FileHandler.names is None:
-            FileHandler.names = (socket.gethostbyname('localhost'),
-                                 socket.gethostbyname(socket.gethostname()))
+            try:
+                FileHandler.names = (socket.gethostbyname('localhost'),
+                                    socket.gethostbyname(socket.gethostname()))
+            except socket.gaierror:
+                FileHandler.names = (socket.gethostbyname('localhost'),)
         return FileHandler.names
 
     # not entirely sure what the rules are here


More information about the Python-checkins mailing list