summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2013-06-01 18:12:17 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2013-06-01 18:12:17 (GMT)
commitdcdadfe39afd9b7cddf1e20efa37babdad61ff77 (patch)
tree1c1c9c64efd8ee8bf533bb1c98cb05d451d6ddcf
parent4e42ae81f6a45f40a3f6a64192575bfc44f61bdb (diff)
downloadcpython-dcdadfe39afd9b7cddf1e20efa37babdad61ff77.zip
cpython-dcdadfe39afd9b7cddf1e20efa37babdad61ff77.tar.gz
cpython-dcdadfe39afd9b7cddf1e20efa37babdad61ff77.tar.bz2
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.
-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 1279322..30e43e6 100644
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -2229,7 +2229,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