summaryrefslogtreecommitdiffstats
path: root/Lib/textwrap.py
diff options
context:
space:
mode:
authorGreg Ward <gward@python.net>2002-12-09 16:26:05 (GMT)
committerGreg Ward <gward@python.net>2002-12-09 16:26:05 (GMT)
commitab73d46e45eae94fb8be040ccb32d3510b8f58fa (patch)
tree390cda84176e41d527985d5b3bc5c4abe7d83d47 /Lib/textwrap.py
parent2e74541d7e715f3333a3d2bf0e9cac79f3871e0c (diff)
downloadcpython-ab73d46e45eae94fb8be040ccb32d3510b8f58fa.zip
cpython-ab73d46e45eae94fb8be040ccb32d3510b8f58fa.tar.gz
cpython-ab73d46e45eae94fb8be040ccb32d3510b8f58fa.tar.bz2
Fix SF bug #622849: in _wrap_chunks(), ensure that leading whitespace in
the input string is always preserved.
Diffstat (limited to 'Lib/textwrap.py')
-rw-r--r--Lib/textwrap.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/textwrap.py b/Lib/textwrap.py
index fc93b9b..5860d7d 100644
--- a/Lib/textwrap.py
+++ b/Lib/textwrap.py
@@ -202,8 +202,9 @@ class TextWrapper:
# Maximum width for this line.
width = self.width - len(indent)
- # First chunk on line is whitespace -- drop it.
- if chunks[0].strip() == '':
+ # First chunk on line is whitespace -- drop it, unless this
+ # is the very beginning of the text (ie. no lines started yet).
+ if chunks[0].strip() == '' and lines:
del chunks[0]
while chunks: