]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Fix thishost helper funtion in urllib. Returns the ipaddress of localhost when
authorSenthil Kumaran <senthil@uthcode.com>
Sat, 1 Jun 2013 18:11:30 +0000 (11:11 -0700)
committerSenthil Kumaran <senthil@uthcode.com>
Sat, 1 Jun 2013 18:11:30 +0000 (11:11 -0700)
hostname is resolvable by socket.gethostname for local machine. This all fixes
certain freebsd builtbot failures.

Lib/urllib.py

index 32b4919f07fb2b10e26784341a221de39db1db58..09a054b623cbcb5b4e02ffeda16cb18757ca43a0 100644 (file)
@@ -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