diff options
author | Sylvain <syt@logilab.fr> | 2006-10-02 11:45:00 +0200 |
---|---|---|
committer | Sylvain <syt@logilab.fr> | 2006-10-02 11:45:00 +0200 |
commit | f3c804163960efa28561805316b3667474e14fe3 (patch) | |
tree | 2b244a3304e9bf3b39b84b683e969eee03dd7a88 | |
parent | 5cb624cbeba2fe39e0bb2f7ace02008b60b517d9 (diff) | |
download | logilab-common-f3c804163960efa28561805316b3667474e14fe3.tar.gz |
* fixed bug in textutils.normalise_[text|paragraph] with unsplitable
word larger than the maximum line size
-rw-r--r-- | ChangeLog | 4 | ||||
-rw-r--r-- | test/unittest_textutils.py | 10 | ||||
-rw-r--r-- | textutils.py | 2 |
3 files changed, 15 insertions, 1 deletions
@@ -1,6 +1,10 @@ ChangeLog for logilab.common ============================ + -- + * fixed bug in textutils.normalise_[text|paragraph] with unsplitable + word larger than the maximum line size + 2006-09-25 -- 0.19.2 * testlib: - fixed a bug in find_test making it returns some bad test names diff --git a/test/unittest_textutils.py b/test/unittest_textutils.py index 855585d..b053035 100644 --- a/test/unittest_textutils.py +++ b/test/unittest_textutils.py @@ -37,6 +37,16 @@ linnnnnnnnnnnes and empty lines!''') + def test_nonregr_unsplitable_word(self): + self.assertEquals(ulines(tu.normalize_text('''petit complement : + +http://www.plonefr.net/blog/archive/2005/10/30/tester-la-future-infrastructure-i18n +''', 80)), + '''petit complement : + +http://www.plonefr.net/blog/archive/2005/10/30/tester-la-future-infrastructure-i18n''') + + class NormalizeParagraphTC(TestCase): def test_known_values(self): diff --git a/textutils.py b/textutils.py index e4b725f..17ccbfe 100644 --- a/textutils.py +++ b/textutils.py @@ -152,7 +152,7 @@ def normalize_paragraph(text, line_len=80, indent=''): if pos == 0: pos = min(len(indent) + len(text), line_len) pos = pos - len(indent) - while text[pos] != ' ': + while len(text) > pos and text[pos] != ' ': pos += 1 lines.append((indent + text[:pos])) text = text[pos+1:] |