]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-21016: pydoc and trace use sysconfig (GH-18476)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 12 Feb 2020 12:32:46 +0000 (04:32 -0800)
committerGitHub <noreply@github.com>
Wed, 12 Feb 2020 12:32:46 +0000 (04:32 -0800)
bpo-21016, bpo-1294959: The pydoc and trace modules now use the
sysconfig module to get the path to the Python standard library, to
support uncommon installation path like /usr/lib64/python3.9/ on
Fedora.

Co-Authored-By: Jan Matějek <jmatejek@suse.com>
(cherry picked from commit 4fac7ed43ebf1771a8fe86fdfe7b9991f3be78cd)

Co-authored-by: Victor Stinner <vstinner@python.org>
Lib/pydoc.py
Lib/trace.py
Misc/NEWS.d/next/Library/2020-02-12-10-04-39.bpo-21016.bFXPH7.rst [new file with mode: 0644]

index 44df8c854ae9edba7087037dc7b520f4a5c5a4df..978e4cd0baa5ba381244b0f234393639304057c4 100644 (file)
@@ -66,6 +66,7 @@ import pkgutil
 import platform
 import re
 import sys
+import sysconfig
 import time
 import tokenize
 import urllib.parse
@@ -398,9 +399,7 @@ class Doc:
 
     docmodule = docclass = docroutine = docother = docproperty = docdata = fail
 
-    def getdocloc(self, object,
-                  basedir=os.path.join(sys.base_exec_prefix, "lib",
-                                       "python%d.%d" %  sys.version_info[:2])):
+    def getdocloc(self, object, basedir=sysconfig.get_path('stdlib')):
         """Return the location of module docs or None"""
 
         try:
index 206bd2b689f118cdb37e335d13b0e900c729dc64..c804a0d75669aac80f969abd4719af35084d4519 100755 (executable)
@@ -53,6 +53,7 @@ import linecache
 import os
 import re
 import sys
+import sysconfig
 import token
 import tokenize
 import inspect
@@ -671,9 +672,8 @@ def main():
     opts = parser.parse_args()
 
     if opts.ignore_dir:
-        rel_path = 'lib', 'python{0.major}.{0.minor}'.format(sys.version_info)
-        _prefix = os.path.join(sys.base_prefix, *rel_path)
-        _exec_prefix = os.path.join(sys.base_exec_prefix, *rel_path)
+        _prefix = sysconfig.get_path("stdlib")
+        _exec_prefix = sysconfig.get_path("platstdlib")
 
     def parse_ignore_dir(s):
         s = os.path.expanduser(os.path.expandvars(s))
diff --git a/Misc/NEWS.d/next/Library/2020-02-12-10-04-39.bpo-21016.bFXPH7.rst b/Misc/NEWS.d/next/Library/2020-02-12-10-04-39.bpo-21016.bFXPH7.rst
new file mode 100644 (file)
index 0000000..fb91bb3
--- /dev/null
@@ -0,0 +1,4 @@
+The :mod:`pydoc` and :mod:`trace` modules now use the :mod:`sysconfig`
+module to get the path to the Python standard library, to support uncommon
+installation path like ``/usr/lib64/python3.9/`` on Fedora.
+Patch by Jan Matějek.