Author: Manuel Jacob <m...@manueljacob.de> Branch: Changeset: r82379:337c536c54c1 Date: 2016-02-22 02:04 +0100 http://bitbucket.org/pypy/pypy/changeset/337c536c54c1/
Log: Fix translation. diff --git a/pypy/interpreter/pyparser/pytokenizer.py b/pypy/interpreter/pyparser/pytokenizer.py --- a/pypy/interpreter/pyparser/pytokenizer.py +++ b/pypy/interpreter/pyparser/pytokenizer.py @@ -261,14 +261,13 @@ token_list.append((tokens.ENDMARKER, '', lnum, pos, line)) return token_list + def universal_newline(line): - if len(line) >= 2: - c0 = line[-2] - c1 = line[-1] - if c0 == '\r' and c1 == '\n': - return line[:-2] + '\n' - if len(line) >= 1: - c = line[-1] - if c == '\r': - return line[:-1] + '\n' + # show annotator that indexes below are non-negative + line_len_m2 = len(line) - 2 + if line_len_m2 >= 0 and line[-2] == '\r' and line[-1] == '\n': + return line[:line_len_m2] + '\n' + line_len_m1 = len(line) - 1 + if line_len_m1 >= 0 and line[-1] == '\r': + return line[:line_len_m1] + '\n' return line _______________________________________________ pypy-commit mailing list pypy-commit@python.org https://mail.python.org/mailman/listinfo/pypy-commit