[Python-checkins] cpython (3.3): Fix thishost helper funtion in urllib. Returns the ipaddress of localhost when
senthil.kumaran
python-checkins at python.org
Sat Jun 1 20:12:59 CEST 2013
http://hg.python.org/cpython/rev/b6464827bddb
changeset: 84011:b6464827bddb
branch: 3.3
parent: 84007:dbfbdf2b5c19
user: Senthil Kumaran <senthil at uthcode.com>
date: Sat Jun 01 11:12:17 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/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
@@ -2229,7 +2229,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