[pypy-commit] pypy py3k: hg merge default

mjacob pypy.commits at gmail.com
Sun Feb 21 20:10:12 EST 2016


Author: Manuel Jacob <me at manueljacob.de>
Branch: py3k
Changeset: r82380:688a132b06b6
Date: 2016-02-22 02:04 +0100
http://bitbucket.org/pypy/pypy/changeset/688a132b06b6/

Log:	hg merge default

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