[ python-Bugs-1250170 ] gethostbyname(gethostname()) fails on misconfigured system

SourceForge.net noreply at sourceforge.net
Fri Sep 30 08:33:50 CEST 2005


Bugs item #1250170, was opened at 2005-08-02 05:17
Message generated for change (Comment added) made by nnorwitz
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1250170&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Tadeusz Andrzej Kadlubowski (tkadlubo)
Assigned to: Nobody/Anonymous (nobody)
Summary: gethostbyname(gethostname()) fails on misconfigured system

Initial Comment:
Hello,

I downloaded python CVS tree, compiled it and ran tests. 

Two tests failed: urllib2 and mimetools. Both in the same fashion, 
when doing socket.gethostbyname(socket.gethostname())

(It is used in mimetools.py library in line 130 and in test_urllib2.py 
test unit in line 352.)

In the interpreter it fails in the following way:

>>> import socket
>>> socket.gethostbyname(socket.gethostname())
Traceback (most recent call last):
  File "<stdin>", line 1, in ?
socket.gaierror: (-2, 'Name or service not known')

The reason is that my hostname is bogus, no single DNS knows 
about it, and I don't see any reason to set up a DNS server on my 
box. Of course editing /etc/hosts and adding my hostname as an 
alias for 127.0.0.1 solves the problem.

Anyway I don't see any particular reason why the library shouldn't 
handle such situation i.e. when there's no connection between 
hostname and IP address.

What do you think about it? I can make a SF patch item to solve 
this issue if you like. I am quite sure adding try/catch will make it 
in both cases.

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

>Comment By: Neal Norwitz (nnorwitz)
Date: 2005-09-29 23:33

Message:
Logged In: YES 
user_id=33168

Please provide a patch and attach it to this report.  Thanks.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1250170&group_id=5470


More information about the Python-bugs-list mailing list