diff options
author | Georg Brandl <georg@python.org> | 2006-04-02 20:37:17 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2006-04-02 20:37:17 (GMT) |
commit | 4eb521e595216a406ad1d3175056dc8cd8be157b (patch) | |
tree | 85491c7b55a4ad01bc4b0b6deceeeddee2be7b44 /Lib/urllib2.py | |
parent | 31fe35bdeeaf231130784140597cc680902b8979 (diff) | |
download | cpython-4eb521e595216a406ad1d3175056dc8cd8be157b.zip cpython-4eb521e595216a406ad1d3175056dc8cd8be157b.tar.gz cpython-4eb521e595216a406ad1d3175056dc8cd8be157b.tar.bz2 |
bug #1462706: guard against host not having FQDN hostname
Diffstat (limited to 'Lib/urllib2.py')
-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 c3afae6..21f916c 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 |