summaryrefslogtreecommitdiffstats
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorZachary Ware <zachary.ware@gmail.com>2014-07-10 16:18:00 (GMT)
committerZachary Ware <zachary.ware@gmail.com>2014-07-10 16:18:00 (GMT)
commiteb43214427b1ae6d7095bdd2333e9bc2220f9449 (patch)
tree77bc2894579fc239b8d6f6e3f4fbfc358901b525 /Lib/pydoc.py
parent7cca28ffa2efff47d4c53080f49c5b5c8eebbc19 (diff)
downloadcpython-eb43214427b1ae6d7095bdd2333e9bc2220f9449.zip
cpython-eb43214427b1ae6d7095bdd2333e9bc2220f9449.tar.gz
cpython-eb43214427b1ae6d7095bdd2333e9bc2220f9449.tar.bz2
Issue #21942: Fixed source file viewing in pydoc's server mode on Windows.
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index cc43684..37abf67 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
@@ -648,10 +649,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)'
@@ -2353,7 +2351,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