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

pydoc -p 0 says the server is available at localhost:0 #63105

Closed
mineo mannequin opened this issue Sep 2, 2013 · 4 comments
Closed

pydoc -p 0 says the server is available at localhost:0 #63105

mineo mannequin opened this issue Sep 2, 2013 · 4 comments
Assignees
Labels
stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@mineo
Copy link
Mannequin

mineo mannequin commented Sep 2, 2013

BPO 18905
Nosy @berkerpeksag, @serhiy-storchaka, @mineo
Files
  • pydoc-port.patch
  • pydoc_port_2.patch
  • 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 = 'https://github.com/serhiy-storchaka'
    closed_at = <Date 2014-11-27.22:54:39.273>
    created_at = <Date 2013-09-02.16:49:20.249>
    labels = ['type-bug', 'library']
    title = 'pydoc -p 0 says the server is available at localhost:0'
    updated_at = <Date 2014-11-27.22:54:39.272>
    user = 'https://github.com/mineo'

    bugs.python.org fields:

    activity = <Date 2014-11-27.22:54:39.272>
    actor = 'serhiy.storchaka'
    assignee = 'serhiy.storchaka'
    closed = True
    closed_date = <Date 2014-11-27.22:54:39.273>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)']
    creation = <Date 2013-09-02.16:49:20.249>
    creator = 'Wieland.Hoffmann'
    dependencies = []
    files = ['31556', '37225']
    hgrepos = []
    issue_num = 18905
    keywords = ['patch']
    message_count = 4.0
    messages = ['196789', '231356', '231784', '231787']
    nosy_count = 4.0
    nosy_names = ['python-dev', 'berker.peksag', 'serhiy.storchaka', 'Wieland.Hoffmann']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue18905'
    versions = ['Python 2.7']

    @mineo
    Copy link
    Mannequin Author

    mineo mannequin commented Sep 2, 2013

    In Python 3 one can use pydoc -p 0 to start a pydoc HTTP server on an arbitrary unused port. This works (somewhat) in Python 2 as well, except that pydoc doesn't tell you which port it's listening on. Applying the attached patch makes pydoc print the correct port.

    @mineo mineo mannequin added stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error labels Sep 2, 2013
    @serhiy-storchaka
    Copy link
    Member

    With the patch resolved address 127.0.0.1 is printed instead of localhost. self.address[0] can be used to match current behavior of 2.7 and 3.x.

    And why not just initialize the url attribute in server_activate()?

    @serhiy-storchaka serhiy-storchaka self-assigned this Nov 19, 2014
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Nov 27, 2014

    New changeset ac7f3161aa53 by Serhiy Storchaka in branch '2.7':
    Issue bpo-18905: "pydoc -p 0" now outputs actually used port. Based on patch by
    https://hg.python.org/cpython/rev/ac7f3161aa53

    @serhiy-storchaka
    Copy link
    Member

    Thank you for your patch Wieland.

    @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
    stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant