Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit aa72b1b

Browse files
committed
Merge from 3.3
Issue #22421 - Secure pydoc server run. Bind it to localhost instead of all interfaces.
2 parents f75805e + 2a42a0b commit aa72b1b

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

Lib/pydoc.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2178,8 +2178,8 @@ def log_message(self, *args):
21782178
class DocServer(http.server.HTTPServer):
21792179

21802180
def __init__(self, port, callback):
2181-
self.host = (sys.platform == 'mac') and '127.0.0.1' or 'localhost'
2182-
self.address = ('', port)
2181+
self.host = 'localhost'
2182+
self.address = (self.host, port)
21832183
self.callback = callback
21842184
self.base.__init__(self, self.address, self.handler)
21852185
self.quit = False

Lib/test/test_pydoc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -803,6 +803,8 @@ def my_url_handler(url, content_type):
803803
return text
804804

805805
serverthread = pydoc._start_server(my_url_handler, port=0)
806+
self.assertIn('localhost', serverthread.docserver.address)
807+
806808
starttime = time.time()
807809
timeout = 1 #seconds
808810

0 commit comments

Comments
 (0)