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>
(cherry picked from commit 4fac7ed43ebf1771a8fe86fdfe7b9991f3be78cd)
Co-authored-by: Victor Stinner <vstinner@python.org>
diff --git a/Lib/trace.py b/Lib/trace.py
index 62325d3..a447357 100755
--- a/Lib/trace.py
+++ b/Lib/trace.py
@@ -52,6 +52,7 @@
import linecache
import os
import sys
+import sysconfig
import token
import tokenize
import inspect
@@ -676,9 +677,8 @@
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))