summaryrefslogtreecommitdiffstats
path: root/Lib/urllib
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2013-06-01 18:12:52 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2013-06-01 18:12:52 (GMT)
commit88249b80d7f374401e61fee4e08e446b03bb613d (patch)
tree8ba52bb9156ec4139cf1cd1fe3abbee29f9783ff /Lib/urllib
parentedf33c0145c394694bbcb44a2aaedea0816b9b9e (diff)
parentdcdadfe39afd9b7cddf1e20efa37babdad61ff77 (diff)
downloadcpython-88249b80d7f374401e61fee4e08e446b03bb613d.zip
cpython-88249b80d7f374401e61fee4e08e446b03bb613d.tar.gz
cpython-88249b80d7f374401e61fee4e08e446b03bb613d.tar.bz2
merge from 3.3
Fix thishost helper funtion in urllib. Returns the ipaddress of localhost when hostname is resolvable by socket.gethostname for local machine. This all fixes certain freebsd builtbot failures.
Diffstat (limited to 'Lib/urllib')
-rw-r--r--Lib/urllib/request.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
index 1de6aae..84f177c 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -2259,7 +2259,10 @@ def thishost():
"""Return the IP addresses of the current host."""
global _thishost
if _thishost is None:
- _thishost = tuple(socket.gethostbyname_ex(socket.gethostname())[2])
+ try:
+ _thishost = tuple(socket.gethostbyname_ex(socket.gethostname())[2])
+ except socket.gaierror:
+ _thishost = tuple(socket.gethostbyname_ex('localhost')[2])
return _thishost
_ftperrors = None