diff options
author | Senthil Kumaran <senthil@uthcode.com> | 2013-06-01 18:12:52 (GMT) |
---|---|---|
committer | Senthil Kumaran <senthil@uthcode.com> | 2013-06-01 18:12:52 (GMT) |
commit | 88249b80d7f374401e61fee4e08e446b03bb613d (patch) | |
tree | 8ba52bb9156ec4139cf1cd1fe3abbee29f9783ff /Lib/urllib | |
parent | edf33c0145c394694bbcb44a2aaedea0816b9b9e (diff) | |
parent | dcdadfe39afd9b7cddf1e20efa37babdad61ff77 (diff) | |
download | cpython-88249b80d7f374401e61fee4e08e446b03bb613d.zip cpython-88249b80d7f374401e61fee4e08e446b03bb613d.tar.gz cpython-88249b80d7f374401e61fee4e08e446b03bb613d.tar.bz2 |
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.
Diffstat (limited to 'Lib/urllib')
-rw-r--r-- | Lib/urllib/request.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/urllib/request.py b/Lib/urllib/request.py index 1de6aae..84f177c 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -2259,7 +2259,10 @@ def thishost(): """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 |