diff options
| author | Senthil Kumaran <senthil@uthcode.com> | 2013-06-01 11:12:17 -0700 |
|---|---|---|
| committer | Senthil Kumaran <senthil@uthcode.com> | 2013-06-01 11:12:17 -0700 |
| commit | dcdadfe39afd9b7cddf1e20efa37babdad61ff77 (patch) | |
| tree | 1c1c9c64efd8ee8bf533bb1c98cb05d451d6ddcf | |
| parent | 4e42ae81f6a45f40a3f6a64192575bfc44f61bdb (diff) | |
| download | cpython-git-dcdadfe39afd9b7cddf1e20efa37babdad61ff77.tar.gz | |
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.
| -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 1279322496..30e43e6f9f 100644 --- a/Lib/urllib/request.py +++ b/Lib/urllib/request.py @@ -2229,7 +2229,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 |
