Skip to content

Commit 4fac7ed

Browse files
vstinnerJan Matějek
and
Jan Matějek
authored
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 <[email protected]>
1 parent 8c579b1 commit 4fac7ed

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

Lib/pydoc.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ class or function within a module or module in a package. If the
6666
import platform
6767
import re
6868
import sys
69+
import sysconfig
6970
import time
7071
import tokenize
7172
import urllib.parse
@@ -392,9 +393,7 @@ def fail(self, object, name=None, *args):
392393

393394
docmodule = docclass = docroutine = docother = docproperty = docdata = fail
394395

395-
def getdocloc(self, object,
396-
basedir=os.path.join(sys.base_exec_prefix, "lib",
397-
"python%d.%d" % sys.version_info[:2])):
396+
def getdocloc(self, object, basedir=sysconfig.get_path('stdlib')):
398397
"""Return the location of module docs or None"""
399398

400399
try:

Lib/trace.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@
5252
import linecache
5353
import os
5454
import sys
55+
import sysconfig
5556
import token
5657
import tokenize
5758
import inspect
@@ -660,9 +661,8 @@ def main():
660661
opts = parser.parse_args()
661662

662663
if opts.ignore_dir:
663-
rel_path = 'lib', 'python{0.major}.{0.minor}'.format(sys.version_info)
664-
_prefix = os.path.join(sys.base_prefix, *rel_path)
665-
_exec_prefix = os.path.join(sys.base_exec_prefix, *rel_path)
664+
_prefix = sysconfig.get_path("stdlib")
665+
_exec_prefix = sysconfig.get_path("platstdlib")
666666

667667
def parse_ignore_dir(s):
668668
s = os.path.expanduser(os.path.expandvars(s))
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
The :mod:`pydoc` and :mod:`trace` modules now use the :mod:`sysconfig`
2+
module to get the path to the Python standard library, to support uncommon
3+
installation path like ``/usr/lib64/python3.9/`` on Fedora.
4+
Patch by Jan Matějek.

0 commit comments

Comments
 (0)