[issue5626] misleading comment in socket.gethostname() documentation

Ned Deily report at bugs.python.org
Tue Mar 31 18:03:02 CEST 2009


New submission from Ned Deily <nad at acm.org>:

The documentation for socket.gethostname() contains the following 
comment:

"If you want to know the current machine’s IP address, you may want to 
use gethostbyname(gethostname()). This operation assumes that there is a 
valid address-to-host mapping for the host, and the assumption does not 
always hold."

This comment leads to the mistaken assumption that a machine has only 
one IP address, an assumption which results in bugs such as in 
Issue5625.  The comment also does not deal with other address families, 
i.e. IPv6 addresses.  Either the paragraph should be expanded to cover 
multiple addresses and families, requiring the use of other socket 
functions, or the paragraph should simply be removed.

----------
assignee: georg.brandl
components: Documentation
messages: 84816
nosy: georg.brandl, nad
severity: normal
status: open
title: misleading comment in socket.gethostname() documentation
versions: Python 2.6, Python 2.7, Python 3.0, Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue5626>
_______________________________________


More information about the Python-bugs-list mailing list