From: Senthil Kumaran Date: Sat, 1 Jun 2013 18:11:30 +0000 (-0700) Subject: Fix thishost helper funtion in urllib. Returns the ipaddress of localhost when X-Git-Tag: v2.7.6rc1~365 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=7351b66eb9060cce37073bf323f73d79dc3ef488;p=thirdparty%2FPython%2Fcpython.git 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. --- diff --git a/Lib/urllib.py b/Lib/urllib.py index 32b4919f07fb..09a054b623cb 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