[Python-Dev] test_mimetools failure when hostname unknown.

Guido van Rossum guido at python.org
Fri Nov 28 23:32:13 EST 2003


> If you have a machine who's local hostname is just something you've
> set, and there's no matching entry in /etc/hosts, test_mimetools fails
> with 
> test test_mimetools failed -- Traceback (most recent call last):
>   File "/home/anthony/src/py/23maint/Lib/test/test_mimetools.py", line 30, in test_boundary
>     nb = mimetools.choose_boundary()
>   File "/home/anthony/src/py/23maint/Lib/mimetools.py", line 130, in choose_boundary
>     hostid = socket.gethostbyname(socket.gethostname())
> gaierror: (-2, 'Name or service not known')
> 
> This seems, to me, to be a bit bogus - should we just, in this case,
> have some sensible default (maybe just use the hostname, or 127.0.0.1)
> 
> And yes, I know this is not strictly a python bug, but it just popped 
> up while I was building a new system up.

Yeah, in general all tests that use gethostname() are subject to
various kinds of errors like this.  It really shouldn't be used in the
test suite at all.

--Guido van Rossum (home page: http://www.python.org/~guido/)



More information about the Python-Dev mailing list