summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2014-11-27 21:45:37 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2014-11-27 21:45:37 (GMT)
commit86ef95d3fbd121fec1168b87ddfe027273b38cea (patch)
tree9d34a4545d96c6c9a19d3b02ff181fc804157d3a /Lib/pydoc.py
parent2c1f37667d39302b42f05a9d79c219264803a53f (diff)
downloadcpython-86ef95d3fbd121fec1168b87ddfe027273b38cea.zip
cpython-86ef95d3fbd121fec1168b87ddfe027273b38cea.tar.gz
cpython-86ef95d3fbd121fec1168b87ddfe027273b38cea.tar.bz2
Issue #18905: "pydoc -p 0" now outputs actually used port. Based on patch by
Wieland Hoffmann.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py8
1 files changed, 5 insertions, 3 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index dfa1f8e..594e6c7 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -17,7 +17,8 @@ Run "pydoc -k <keyword>" to search for a keyword in the synopsis lines
of all available modules.
Run "pydoc -p <port>" to start an HTTP server on a given port on the
-local machine to generate documentation web pages.
+local machine to generate documentation web pages. Port number 0 can be
+used to get an arbitrary unused port.
For platforms without a command line, "pydoc -g" starts the HTTP server
and also pops up a little window for controlling it.
@@ -2098,7 +2099,6 @@ pydoc</strong> by Ka-Ping Yee &lt;ping@lfw.org&gt;</font>'''
def __init__(self, port, callback):
host = 'localhost'
self.address = (host, port)
- self.url = 'http://%s:%d/' % (host, port)
self.callback = callback
self.base.__init__(self, self.address, self.handler)
@@ -2111,6 +2111,7 @@ pydoc</strong> by Ka-Ping Yee &lt;ping@lfw.org&gt;</font>'''
def server_activate(self):
self.base.server_activate(self)
+ self.url = 'http://%s:%d/' % (self.address[0], self.server_port)
if self.callback: self.callback(self)
DocServer.base = BaseHTTPServer.HTTPServer
@@ -2384,7 +2385,8 @@ def cli():
Search for a keyword in the synopsis lines of all available modules.
%s -p <port>
- Start an HTTP server on the given port on the local machine.
+ Start an HTTP server on the given port on the local machine. Port
+ number 0 can be used to get an arbitrary unused port.
%s -g
Pop up a graphical interface for finding and serving documentation.