[pypy-commit] pypy py3.3: hg merge py3k
mjacob
pypy.commits at gmail.com
Sun Feb 21 20:10:14 EST 2016
Author: Manuel Jacob <me at manueljacob.de>
Branch: py3.3
Changeset: r82381:9234b0c20972
Date: 2016-02-22 02:05 +0100
http://bitbucket.org/pypy/pypy/changeset/9234b0c20972/
Log: hg merge py3k
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
@@ -298,14 +298,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
More information about the pypy-commit
mailing list