From: Georg Brandl Date: Sun, 2 Apr 2006 20:37:17 +0000 (+0000) Subject: bug #1462706: guard against host not having FQDN hostname X-Git-Tag: v2.5a1~78 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=4eb521e595216a406ad1d3175056dc8cd8be157b;p=thirdparty%2FPython%2Fcpython.git bug #1462706: guard against host not having FQDN hostname --- diff --git a/Lib/urllib2.py b/Lib/urllib2.py index c3afae64940b..21f916ce568a 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