summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-02-12 12:02:29 (GMT)
committerGitHub <noreply@github.com>2020-02-12 12:02:29 (GMT)
commit4fac7ed43ebf1771a8fe86fdfe7b9991f3be78cd (patch)
tree492868bf58bacf625bba43b28d1c9205890db609
parent8c579b1cc86053473eb052b76327279476740c9b (diff)
downloadcpython-4fac7ed43ebf1771a8fe86fdfe7b9991f3be78cd.zip
cpython-4fac7ed43ebf1771a8fe86fdfe7b9991f3be78cd.tar.gz
cpython-4fac7ed43ebf1771a8fe86fdfe7b9991f3be78cd.tar.bz2
bpo-21016: pydoc and trace use sysconfig (GH-18476)
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>
-rwxr-xr-xLib/pydoc.py5
-rwxr-xr-xLib/trace.py6
-rw-r--r--Misc/NEWS.d/next/Library/2020-02-12-10-04-39.bpo-21016.bFXPH7.rst4
3 files changed, 9 insertions, 6 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index e32fdf7..f172700 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -66,6 +66,7 @@ import pkgutil
import platform
import re
import sys
+import sysconfig
import time
import tokenize
import urllib.parse
@@ -392,9 +393,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:
diff --git a/Lib/trace.py b/Lib/trace.py
index 681c3f9..52047c3 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -52,6 +52,7 @@ __all__ = ['Trace', 'CoverageResults']
import linecache
import os
import sys
+import sysconfig
import token
import tokenize
import inspect
@@ -660,9 +661,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
index 0000000..fb91bb3
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-02-12-10-04-39.bpo-21016.bFXPH7.rst
@@ -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.