summaryrefslogtreecommitdiff
path: root/Lib/pydoc.py
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2022-06-27 13:33:34 +0300
committerGitHub <noreply@github.com>2022-06-27 13:33:34 +0300
commit33fc3b5e42f241ab81cc6d115711545b4f9e271e (patch)
tree968b2097985e09020379d09359ce8f9c5c085d9f /Lib/pydoc.py
parentf5c85aa3eea1adf0c61089583e2251282a316ec1 (diff)
downloadcpython-git-33fc3b5e42f241ab81cc6d115711545b4f9e271e.tar.gz
gh-94318: Strip trailing spaces in pydoc text output (GH-94319)
Diffstat (limited to 'Lib/pydoc.py')
-rwxr-xr-xLib/pydoc.py3
1 files changed, 1 insertions, 2 deletions
diff --git a/Lib/pydoc.py b/Lib/pydoc.py
index e96cacbe43..a4dc910c8a 100755
--- a/Lib/pydoc.py
+++ b/Lib/pydoc.py
@@ -1171,8 +1171,7 @@ class TextDoc(Doc):
def indent(self, text, prefix=' '):
"""Indent text by prepending a given prefix to each line."""
if not text: return ''
- lines = [prefix + line for line in text.split('\n')]
- if lines: lines[-1] = lines[-1].rstrip()
+ lines = [(prefix + line).rstrip() for line in text.split('\n')]
return '\n'.join(lines)
def section(self, title, contents):