[Python-checkins] bpo-38786: Add parsing of https links to pydoc (GH-17143)

Tal Einat webhook-mailer at python.org
Wed Nov 13 11:14:21 EST 2019


https://github.com/python/cpython/commit/61289d436661025a3111065482275d49a4850b8d
commit: 61289d436661025a3111065482275d49a4850b8d
branch: master
author: Kirill <iam at python273.pw>
committer: Tal Einat <taleinat+github at gmail.com>
date: 2019-11-13T18:13:52+02:00
summary:

bpo-38786: Add parsing of https links to pydoc (GH-17143)

files:
A Misc/NEWS.d/next/Library/2019-11-13-16-49-03.bpo-38786.gNOwKh.rst
M Lib/pydoc.py
M Lib/test/test_pydoc.py
M Lib/xmlrpc/server.py

diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index 9a22e56686f61..e32fdf76978e2 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 c80477c50f098..b803b8bff2f7f 100644
--- a/Lib/test/test_pydoc.py
+++ b/Lib/test/test_pydoc.py
@@ -1311,6 +1311,17 @@ def test_async_generator_annotation(self):
             'async <a name="-an_async_generator"><strong>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(
+            '<a href="https://localhost/">https://localhost/</a>',
+            html
+        )
+
 class PydocServerTest(unittest.TestCase):
     """Tests for pydoc._start_server"""
 
diff --git a/Lib/xmlrpc/server.py b/Lib/xmlrpc/server.py
index 32aba4df4c7eb..287e3243b10cc 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')
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 0000000000000..f95d773e08c50
--- /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.



More information about the Python-checkins mailing list