summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSenthil Kumaran <senthil@uthcode.com>2013-06-01 18:11:30 (GMT)
committerSenthil Kumaran <senthil@uthcode.com>2013-06-01 18:11:30 (GMT)
commit7351b66eb9060cce37073bf323f73d79dc3ef488 (patch)
treee091bd1016f68194668a7dc886056d713ba4fdc9
parent243cb807e970e19d54fbebea19d6f3130403272d (diff)
downloadcpython-7351b66eb9060cce37073bf323f73d79dc3ef488.zip
cpython-7351b66eb9060cce37073bf323f73d79dc3ef488.tar.gz
cpython-7351b66eb9060cce37073bf323f73d79dc3ef488.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.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py
index 32b4919..09a054b 100644
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -819,7 +819,10 @@ def thishost():
"""Return the IP address of the current host."""
global _thishost
if _thishost is None:
- _thishost = socket.gethostbyname(socket.gethostname())
+ try:
+ _thishost = socket.gethostbyname(socket.gethostname())
+ except socket.gaierror:
+ _thishost = socket.gethostbyname('localhost')
return _thishost
_ftperrors = None