Commit e22b49c0 authored by Bert Massop's avatar Bert Massop

autofix: fix ReplaceTrailingDotsWithEllipsis to accept empty source strings

Having the ReplaceTrailingDotsWithEllipsis autofix enabled results in an _IndexError: string index out of range_ error whenever an empty source string is used (which is unlikely, but not technically impossible).

This patch solves this problem by first checking for non-emptiness of the source string.
parent f75f9d06
......@@ -30,7 +30,7 @@ class ReplaceTrailingDotsWithEllipsis(AutoFix):
name = _('Trailing ellipsis')
def fix_single_target(self, target, source, unit):
if (source[-1] == u'…' and target.endswith('...')):
if (len(source) > 0 and source[-1] == u'…' and target.endswith('...')):
return u'%s…' % target[:-3], True
return target, False
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment