diff options
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/test/test_textwrap.py | 10 | ||||
-rw-r--r-- | Lib/textwrap.py | 2 |
2 files changed, 11 insertions, 1 deletions
diff --git a/Lib/test/test_textwrap.py b/Lib/test/test_textwrap.py index 904c790..a011168 100644 --- a/Lib/test/test_textwrap.py +++ b/Lib/test/test_textwrap.py @@ -305,6 +305,16 @@ How *do* you spell that odd word, anyways? ['Did you say "supercalifragilisticexpialidocious?"', 'How *do* you spell that odd word, anyways?']) + # SF bug 797650. Prevent an infinite loop by making sure that at + # least one character gets split off on every pass. + self.check_wrap('-'*10+'hello', 10, + ['----------', + ' h', + ' e', + ' l', + ' l', + ' o'], + subsequent_indent = ' '*15) def test_nobreak_long(self): # Test with break_long_words disabled diff --git a/Lib/textwrap.py b/Lib/textwrap.py index a4a5498..f371fbb 100644 --- a/Lib/textwrap.py +++ b/Lib/textwrap.py @@ -168,7 +168,7 @@ class TextWrapper: Handle a chunk of text (most likely a word, not whitespace) that is too long to fit in any line. """ - space_left = width - cur_len + space_left = max(width - cur_len, 1) # 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. |