summaryrefslogtreecommitdiff
path: root/Lib/textwrap.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-01-19 19:48:19 +0000
committerGeorg Brandl <georg@python.org>2008-01-19 19:48:19 +0000
commit1729a05927a068cd5dafd6ca09f0404443621a59 (patch)
tree9f14bf67b5976a2b23c1dc0d416bb6ebfe3c3211 /Lib/textwrap.py
parentdcebac6386788051ed917ad6c18a716d39648f15 (diff)
downloadcpython-1729a05927a068cd5dafd6ca09f0404443621a59.tar.gz
Fix #1146: TextWrap vs words 1-character shorter than the width.
Patch by Quentin Gallet-Gilles.
Diffstat (limited to 'Lib/textwrap.py')
-rw-r--r--Lib/textwrap.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/Lib/textwrap.py b/Lib/textwrap.py
index e49644d221..473b98ac97 100644
--- a/Lib/textwrap.py
+++ b/Lib/textwrap.py
@@ -173,7 +173,12 @@ class TextWrapper:
Handle a chunk of text (most likely a word, not whitespace) that
is too long to fit in any line.
"""
- space_left = max(width - cur_len, 1)
+ # Figure out when indent is larger than the specified width, and make
+ # sure at least one character is stripped off on every pass
+ if width < 1:
+ space_left = 1
+ else:
+ space_left = width - cur_len
# If we're allowed to break long words, then do so: put as much
# of the next chunk onto the current line as will fit.