diff options
| -rw-r--r-- | Lib/urllib2.py | 7 |
1 files 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 |
