Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

misleading comment in socket.gethostname() documentation #49876

Closed
ned-deily opened this issue Mar 31, 2009 · 6 comments
Closed

misleading comment in socket.gethostname() documentation #49876

ned-deily opened this issue Mar 31, 2009 · 6 comments
Labels
docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error

Comments

@ned-deily
Copy link
Member

BPO 5626
Nosy @birkenfeld, @orsenthil, @ned-deily, @Rosuav, @berkerpeksag
Files
  • issue5626_v1.diff: Remove misleading comment.
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-01-20.06:46:38.131>
    created_at = <Date 2009-03-31.16:02:52.238>
    labels = ['type-bug', 'docs']
    title = 'misleading comment in socket.gethostname() documentation'
    updated_at = <Date 2016-01-20.06:46:38.130>
    user = 'https://github.com/ned-deily'

    bugs.python.org fields:

    activity = <Date 2016-01-20.06:46:38.130>
    actor = 'berker.peksag'
    assignee = 'docs@python'
    closed = True
    closed_date = <Date 2016-01-20.06:46:38.131>
    closer = 'berker.peksag'
    components = ['Documentation']
    creation = <Date 2009-03-31.16:02:52.238>
    creator = 'ned.deily'
    dependencies = []
    files = ['24698']
    hgrepos = []
    issue_num = 5626
    keywords = ['patch']
    message_count = 6.0
    messages = ['84816', '212554', '258565', '258567', '258601', '258649']
    nosy_count = 7.0
    nosy_names = ['georg.brandl', 'orsenthil', 'ned.deily', 'docs@python', 'python-dev', 'Rosuav', 'berker.peksag']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue5626'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    @ned-deily
    Copy link
    Member Author

    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
    bpo-5625. 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.

    @ned-deily ned-deily added the docs Documentation in the Doc dir label Mar 31, 2009
    @BreamoreBoy BreamoreBoy mannequin assigned docspython and unassigned birkenfeld Jul 31, 2010
    @Rosuav
    Copy link
    Contributor

    Rosuav commented Mar 2, 2014

    Python doesn't currently have any sort of function for fetching all a computer's IPs, as far as I know, but if there is one (either now or in the future), it would be good to link to that from there. "Here's how to get your host name. And if you're interested, over there is how to get your IP addresses." Otherwise, removing the potentially-misleading information (this is going to return something in 127.0.0.0/8 for a lot of systems) seems the reasonable option.

    @orsenthil
    Copy link
    Member

    Given that we have not received any more reports on users tripping up on this message, it seems to me that we could just ignore this report and close it. Thoughts?

    @ned-deily
    Copy link
    Member Author

    The point still stands that speaking of "the current machine's IP address" is misleading at best. I'd say either apply Berker's suggested patch or expand the description to better reflect the real world of multiple interfaces. Of course I'm biased.

    @berkerpeksag
    Copy link
    Member

    I agree with Chris and Ned. I will apply issue5626_v1.diff today.

    @berkerpeksag berkerpeksag added the type-bug An unexpected behavior, bug, or error label Jan 19, 2016
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jan 20, 2016

    New changeset e1a711808cfe by Berker Peksag in branch '3.5':
    Issue bpo-5626: Remove misleading comment from socket.gethostname() documentation
    https://hg.python.org/cpython/rev/e1a711808cfe

    New changeset 689f881dd5d1 by Berker Peksag in branch 'default':
    Issue bpo-5626: Remove misleading comment from socket.gethostname() documentation
    https://hg.python.org/cpython/rev/689f881dd5d1

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    docs Documentation in the Doc dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants