diff options
Diffstat (limited to 'Lib/urllib.py')
-rw-r--r-- | Lib/urllib.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/urllib.py b/Lib/urllib.py index 32b4919..09a054b 100644 --- a/Lib/urllib.py +++ b/Lib/urllib.py @@ -819,7 +819,10 @@ def thishost(): """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 |