bug #1462706: guard against host not having FQDN hostname
diff --git a/Lib/urllib2.py b/Lib/urllib2.py
index c3afae6..21f916c 100644
--- a/Lib/urllib2.py
+++ b/Lib/urllib2.py
@@ -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