[Python-checkins] cpython (merge 3.3 -> default): merge from 3.3

senthil.kumaran python-checkins at python.org
Sat Jun 1 20:13:01 CEST 2013


http://hg.python.org/cpython/rev/25450fff5b90
changeset:   84012:25450fff5b90
parent:      84009:a678f139510b
parent:      84011:b6464827bddb
user:        Senthil Kumaran <senthil at uthcode.com>
date:        Sat Jun 01 11:12:52 2013 -0700
summary:
  merge from 3.3

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.

files:
  Lib/urllib/request.py |  5 ++++-
  1 files changed, 4 insertions(+), 1 deletions(-)


diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py
--- a/Lib/urllib/request.py
+++ b/Lib/urllib/request.py
@@ -2259,7 +2259,10 @@
     """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

-- 
Repository URL: http://hg.python.org/cpython


More information about the Python-checkins mailing list