From 4eb521e595216a406ad1d3175056dc8cd8be157b Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Sun, 2 Apr 2006 20:37:17 +0000 Subject: [PATCH] bug #1462706: guard against host not having FQDN hostname --- Lib/urllib2.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/Lib/urllib2.py b/Lib/urllib2.py index c3afae6494..21f916ce56 100644 --- a/Lib/urllib2.py +++ b/Lib/urllib2.py @@ -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 -- 2.50.1