summaryrefslogtreecommitdiff
path: root/Lib/urllib/request.py
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2013-06-01 11:12:17 -0700
committerSenthil Kumaran <senthil@uthcode.com>2013-06-01 11:12:17 -0700
commitdcdadfe39afd9b7cddf1e20efa37babdad61ff77 (patch)
tree1c1c9c64efd8ee8bf533bb1c98cb05d451d6ddcf /Lib/urllib/request.py
parent4e42ae81f6a45f40a3f6a64192575bfc44f61bdb (diff)
downloadcpython-git-dcdadfe39afd9b7cddf1e20efa37babdad61ff77.tar.gz
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/request.py')
-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 1279322496..30e43e6f9f 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