diff options
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-x | Lib/pydoc.py | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py index adb15c4928..4c67835179 100755 --- a/Lib/pydoc.py +++ b/Lib/pydoc.py @@ -64,6 +64,7 @@ import re import sys import time import tokenize +import urllib.parse import warnings from collections import deque from reprlib import Repr @@ -646,10 +647,7 @@ class HTMLDoc(Doc): head = '<big><big><strong>%s</strong></big></big>' % linkedname try: path = inspect.getabsfile(object) - url = path - if sys.platform == 'win32': - import nturl2path - url = nturl2path.pathname2url(path) + url = urllib.parse.quote(path) filelink = self.filelink(url, path) except TypeError: filelink = '(built-in)' @@ -2350,7 +2348,7 @@ def _url_handler(url, content_type="text/html"): def html_getfile(path): """Get and display a source file listing safely.""" - path = path.replace('%20', ' ') + path = urllib.parse.unquote(path) with tokenize.open(path) as fp: lines = html.escape(fp.read()) body = '<pre>%s</pre>' % lines |