changeset: 101916:ede10138327e branch: 2.7 user: Martin Panter date: Sun Jun 12 05:25:16 2016 +0000 files: Doc/library/pydoc.rst Lib/pydoc.py Lib/test/test_pydoc.py Misc/ACKS Misc/NEWS description: #16484: Change PYTHONDOCS to "https:", and fix links to use lowercase Implementation by Sean Rodman; test by Kaushik Nadikuditi. diff -r c60d2e4f4f96 -r ede10138327e Doc/library/pydoc.rst --- a/Doc/library/pydoc.rst Sun Jun 12 04:38:34 2016 +0000 +++ b/Doc/library/pydoc.rst Sun Jun 12 05:25:16 2016 +0000 @@ -80,7 +80,7 @@ Python interpreter and typed ``import spam``. Module docs for core modules are assumed to reside in -http://docs.python.org/library/. This can be overridden by setting the +https://docs.python.org/library/. This can be overridden by setting the :envvar:`PYTHONDOCS` environment variable to a different URL or to a local directory containing the Library Reference Manual pages. diff -r c60d2e4f4f96 -r ede10138327e Lib/pydoc.py --- a/Lib/pydoc.py Sun Jun 12 04:38:34 2016 +0000 +++ b/Lib/pydoc.py Sun Jun 12 05:25:16 2016 +0000 @@ -28,7 +28,7 @@ Module docs for core modules are assumed to be in - http://docs.python.org/library/ + https://docs.python.org/library/ This can be overridden by setting the PYTHONDOCS environment variable to a different URL or to a local directory containing the Library @@ -374,7 +374,9 @@ docmodule = docclass = docroutine = docother = docproperty = docdata = fail - def getdocloc(self, object): + def getdocloc(self, object, + basedir=os.path.join(sys.exec_prefix, "lib", + "python"+sys.version[0:3])): """Return the location of module docs or None""" try: @@ -383,9 +385,8 @@ file = '(built-in)' docloc = os.environ.get("PYTHONDOCS", - "http://docs.python.org/library") - basedir = os.path.join(sys.exec_prefix, "lib", - "python"+sys.version[0:3]) + "https://docs.python.org/library") + basedir = os.path.normcase(basedir) if (isinstance(object, type(os)) and (object.__name__ in ('errno', 'exceptions', 'gc', 'imp', 'marshal', 'posix', 'signal', 'sys', @@ -393,10 +394,10 @@ (file.startswith(basedir) and not file.startswith(os.path.join(basedir, 'site-packages')))) and object.__name__ not in ('xml.etree', 'test.pydoc_mod')): - if docloc.startswith("http://"): - docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__) + if docloc.startswith(("http://", "https://")): + docloc = "%s/%s" % (docloc.rstrip("/"), object.__name__.lower()) else: - docloc = os.path.join(docloc, object.__name__ + ".html") + docloc = os.path.join(docloc, object.__name__.lower() + ".html") else: docloc = None return docloc diff -r c60d2e4f4f96 -r ede10138327e Lib/test/test_pydoc.py --- a/Lib/test/test_pydoc.py Sun Jun 12 04:38:34 2016 +0000 +++ b/Lib/test/test_pydoc.py Sun Jun 12 05:25:16 2016 +0000 @@ -13,6 +13,7 @@ import xml.etree import types import test.test_support +import xml.etree.ElementTree from collections import namedtuple from test.script_helper import assert_python_ok from test.test_support import (TESTFN, rmtree, reap_children, captured_stdout, @@ -253,6 +254,14 @@ loc = "
Module Docs" return output.strip(), loc +def get_pydoc_link(module): + "Returns a documentation web link of a module" + dirname = os.path.dirname + basedir = dirname(dirname(__file__)) + doc = pydoc.TextDoc() + loc = doc.getdocloc(module, basedir=basedir) + return loc + def get_pydoc_text(module): "Returns pydoc generated output as text" doc = pydoc.TextDoc() @@ -331,6 +340,11 @@ print_diffs(expected_text, result) self.fail("outputs are not equal, see diff above") + def test_mixed_case_module_names_are_lower_cased(self): + # issue16484 + doc_link = get_pydoc_link(xml.etree.ElementTree) + self.assertIn('xml.etree.elementtree', doc_link) + def test_issue8225(self): # Test issue8225 to ensure no doc link appears for xml.etree result, doc_loc = get_pydoc_text(xml.etree) diff -r c60d2e4f4f96 -r ede10138327e Misc/ACKS --- a/Misc/ACKS Sun Jun 12 04:38:34 2016 +0000 +++ b/Misc/ACKS Sun Jun 12 05:25:16 2016 +0000 @@ -965,6 +965,7 @@ R. David Murray Matti Mäki Jörg Müller +Kaushik N Dale Nagata John Nagle Takahiro Nakayama diff -r c60d2e4f4f96 -r ede10138327e Misc/NEWS --- a/Misc/NEWS Sun Jun 12 04:38:34 2016 +0000 +++ b/Misc/NEWS Sun Jun 12 05:25:16 2016 +0000 @@ -13,6 +13,13 @@ Library ------- +Documentation +------------- + +- Issue #16484: Change the default PYTHONDOCS URL to "https:", and fix the + resulting links to use lowercase. Patch by Sean Rodman, test by Kaushik + Nadikuditi. + What's New in Python 2.7.12 release candidate 1? ================================================