classification
Title: urllib.request.thishost() fails on OSX 10.7
Type: Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: ronaldoussoren
Priority: normal Keywords:

Created on 2012-06-22 09:34 by ronaldoussoren, last changed 2012-06-22 09:34 by ronaldoussoren.

Messages (1)
msg163389 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2012-06-22 09:34
I just noticed that test_urllib fails for me because urllib.request.thishost() fails:


======================================================================
ERROR: test_thishost (test.test_urllib.Utility_Tests)
Test the urllib.request.thishost utility function returns a tuple
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/ronald/Projects/python/rw/default/Lib/test/test_urllib.py", line 1155, in test_thishost
    self.assertIsInstance(urllib.request.thishost(), tuple)
  File "/Users/ronald/Projects/python/rw/default/Lib/urllib/request.py", line 2236, in thishost
    _thishost = tuple(socket.gethostbyname_ex(socket.gethostname())[2])
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

----------------------------------------------------------------------


This is because this host's hostname (Gondolin.local) is not in DNS because my mDNSReponder detected a conflict and picked a different name to advertise in the .local zone without updating the hostname.

The reason I report this anyway is that URLopener.open_local_file seems to assume that thishost() cannot fail, and the error condition on my machine could easily happen on other systems as well.

BTW. The use of this host() in URLopener.open_local_file is wrong for other reasons as well: it assumes that the local machine has exactly 1 IP address, and won't correctly detect that a file is local when the IP address is one of the other IP addresses on a multi homed system.
History
Date User Action Args
2012-06-22 09:34:44ronaldoussorencreate