Author: Nate Bragg <n...@cs.tufts.edu> Branch: lstrip_to_empty_string Changeset: r90834:2275619cea33 Date: 2017-03-28 07:10 -0400 http://bitbucket.org/pypy/pypy/changeset/2275619cea33/
Log: If possible, make lstrip consume the whole string. Previously, it would not consume the final character even if it matched, because rpos pointed to the final index. diff --git a/rpython/rtyper/lltypesystem/rstr.py b/rpython/rtyper/lltypesystem/rstr.py --- a/rpython/rtyper/lltypesystem/rstr.py +++ b/rpython/rtyper/lltypesystem/rstr.py @@ -435,7 +435,7 @@ lpos = 0 rpos = s_len - 1 if left: - while lpos < rpos and s.chars[lpos] == ch: + while lpos <= rpos and s.chars[lpos] == ch: lpos += 1 if right: while lpos < rpos + 1 and s.chars[rpos] == ch: @@ -456,7 +456,7 @@ lpos = 0 rpos = s_len - 1 if left: - while lpos < rpos and s.chars[lpos].isspace(): + while lpos <= rpos and s.chars[lpos].isspace(): lpos += 1 if right: while lpos < rpos + 1 and s.chars[rpos].isspace(): @@ -477,7 +477,7 @@ lpos = 0 rpos = s_len - 1 if left: - while lpos < rpos and LLHelpers.ll_contains(s2, s.chars[lpos]): + while lpos <= rpos and LLHelpers.ll_contains(s2, s.chars[lpos]): lpos += 1 if right: while lpos < rpos + 1 and LLHelpers.ll_contains(s2, s.chars[rpos]): _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit