# HG changeset patch # User Thierry Florac # Date 1605268373 -3600 # Node ID 98b00191ce4f578dcfddfa57bdad250927295db9 # Parent 72ceed22e639a6188202f05ecccde60536a20617 Return initial text when length is negative diff -r 72ceed22e639 -r 98b00191ce4f src/pyams_utils/text.py --- a/src/pyams_utils/text.py Fri Nov 13 12:51:19 2020 +0100 +++ b/src/pyams_utils/text.py Fri Nov 13 12:52:53 2020 +0100 @@ -53,9 +53,11 @@ 'This is a long…' >>> get_text_start('This is a long string', 20, 7) 'This is a long string' + >>> get_text_start('This is a long string', -1) + 'This is a long string' """ result = text or '' - if length > len(result): + if (length < 0) or (length > len(result)): return result index = length - 1 text_length = len(result)