]> granicus.if.org Git - python/commitdiff
bug #1462706: guard against host not having FQDN hostname
authorGeorg Brandl <georg@python.org>
Sun, 2 Apr 2006 20:37:17 +0000 (20:37 +0000)
committerGeorg Brandl <georg@python.org>
Sun, 2 Apr 2006 20:37:17 +0000 (20:37 +0000)
Lib/urllib2.py

index c3afae64940b970a9c4afafbbbb4817d38133875..21f916ce568a25cfe65018d07e5ece4d35d19b7c 100644 (file)
@@ -1130,8 +1130,11 @@ class FileHandler(BaseHandler):
     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