This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: pydoc -p 0 says the server is available at localhost:0
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: Wieland.Hoffmann, berker.peksag, python-dev, serhiy.storchaka
Priority: normal Keywords: patch

Created on 2013-09-02 16:49 by Wieland.Hoffmann, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
pydoc-port.patch Wieland.Hoffmann, 2013-09-02 16:49 review
pydoc_port_2.patch serhiy.storchaka, 2014-11-19 07:28 review
Messages (4)
msg196789 - (view) Author: Wieland Hoffmann (Wieland.Hoffmann) * Date: 2013-09-02 16:49
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.
msg231356 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-19 07:28
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()?
msg231784 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-11-27 22:15
New changeset ac7f3161aa53 by Serhiy Storchaka in branch '2.7':
Issue #18905: "pydoc -p 0" now outputs actually used port.  Based on patch by
https://hg.python.org/cpython/rev/ac7f3161aa53
msg231787 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-11-27 22:54
Thank you for your patch Wieland.
History
Date User Action Args
2022-04-11 14:57:50adminsetgithub: 63105
2014-11-27 22:54:39serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2014-11-27 22:54:18serhiy.storchakasetmessages: + msg231787
2014-11-27 22:15:52python-devsetnosy: + python-dev
messages: + msg231784
2014-11-19 07:29:01serhiy.storchakasetfiles: + pydoc_port_2.patch

nosy: + serhiy.storchaka
messages: + msg231356

assignee: serhiy.storchaka
stage: patch review
2013-09-07 17:56:37berker.peksagsetnosy: + berker.peksag
2013-09-02 16:49:20Wieland.Hoffmanncreate