From b8c65289ec23b119db21d995cc6c000b49360c9e Mon Sep 17 00:00:00 2001 From: python273 Date: Wed, 13 Nov 2019 16:10:00 +0300 Subject: [PATCH 1/2] pydoc html: parse https links --- Lib/pydoc.py | 2 +- Lib/test/test_pydoc.py | 11 +++++++++++ Lib/xmlrpc/server.py | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/Lib/pydoc.py b/Lib/pydoc.py index 9a22e56686f618..e32fdf76978e26 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -585,7 +585,7 @@ def markup(self, text, escape=None, funcs={}, classes={}, methods={}): escape = escape or self.escape results = [] here = 0 - pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|' + pattern = re.compile(r'\b((http|https|ftp)://\S+[\w/]|' r'RFC[- ]?(\d+)|' r'PEP[- ]?(\d+)|' r'(self\.)?(\w+))') diff --git a/Lib/test/test_pydoc.py b/Lib/test/test_pydoc.py index c80477c50f0980..b803b8bff2f7f8 100644 --- a/Lib/test/test_pydoc.py +++ b/Lib/test/test_pydoc.py @@ -1311,6 +1311,17 @@ async def an_async_generator(): 'async an_async_generator', html) + def test_html_for_https_links(self): + def a_fn_with_https_link(): + """a link https://localhost/""" + pass + + html = pydoc.HTMLDoc().document(a_fn_with_https_link) + self.assertIn( + 'https://localhost/', + html + ) + class PydocServerTest(unittest.TestCase): """Tests for pydoc._start_server""" diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py index 32aba4df4c7eb5..287e3243b10cc5 100644 --- a/Lib/xmlrpc/server.py +++ b/Lib/xmlrpc/server.py @@ -732,7 +732,7 @@ def markup(self, text, escape=None, funcs={}, classes={}, methods={}): # hyperlinking of arbitrary strings being used as method # names. Only methods with names consisting of word characters # and '.'s are hyperlinked. - pattern = re.compile(r'\b((http|ftp)://\S+[\w/]|' + pattern = re.compile(r'\b((http|https|ftp)://\S+[\w/]|' r'RFC[- ]?(\d+)|' r'PEP[- ]?(\d+)|' r'(self\.)?((?:\w|\.)+))\b') From 00f7a93c2dae850e03d2cf0402203d543e84a40e Mon Sep 17 00:00:00 2001 From: Tal Einat Date: Wed, 13 Nov 2019 16:49:16 +0200 Subject: [PATCH 2/2] add a NEWS entry --- .../NEWS.d/next/Library/2019-11-13-16-49-03.bpo-38786.gNOwKh.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 Misc/NEWS.d/next/Library/2019-11-13-16-49-03.bpo-38786.gNOwKh.rst diff --git a/Misc/NEWS.d/next/Library/2019-11-13-16-49-03.bpo-38786.gNOwKh.rst b/Misc/NEWS.d/next/Library/2019-11-13-16-49-03.bpo-38786.gNOwKh.rst new file mode 100644 index 00000000000000..f95d773e08c502 --- /dev/null +++ b/Misc/NEWS.d/next/Library/2019-11-13-16-49-03.bpo-38786.gNOwKh.rst @@ -0,0 +1 @@ +pydoc now recognizes and parses HTTPS URLs. Patch by python273.