[Python-checkins] cpython (2.7): Fix thishost helper funtion in urllib. Returns the ipaddress of localhost when
senthil.kumaran
python-checkins at python.org
Sat Jun 1 20:12:58 CEST 2013
http://hg.python.org/cpython/rev/4657d0eebe42
changeset: 84010:4657d0eebe42
branch: 2.7
parent: 84006:0a544bb539e6
user: Senthil Kumaran <senthil at uthcode.com>
date: Sat Jun 01 11:11:30 2013 -0700
summary:
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.py | 5 ++++-
1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/Lib/urllib.py b/Lib/urllib.py
--- a/Lib/urllib.py
+++ b/Lib/urllib.py
@@ -819,7 +819,10 @@
"""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
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list