Author: Armin Rigo <[email protected]>
Branch: py3k
Changeset: r87606:423e1e4247ea
Date: 2016-10-05 22:49 +0200
http://bitbucket.org/pypy/pypy/changeset/423e1e4247ea/

Log:    Nonsense occurs in SyntaxErrors with continuation lines (ending in
        '\'). At least for now avoid crashes (test_codeop.py, which fails
        randomly)

diff --git a/pypy/interpreter/pyparser/error.py 
b/pypy/interpreter/pyparser/error.py
--- a/pypy/interpreter/pyparser/error.py
+++ b/pypy/interpreter/pyparser/error.py
@@ -18,6 +18,11 @@
             from rpython.rlib.runicode import str_decode_utf_8
             # self.text may not be UTF-8 in case of decoding errors.
             # adjust the encoded text offset to a decoded offset
+            # XXX do the right thing about continuation lines, which
+            # XXX are their own fun, sometimes giving offset >
+            # XXX len(self.text) for example (right now, avoid crashing)
+            if offset > len(self.text):
+                offset = len(self.text)
             text, _ = str_decode_utf_8(self.text, offset, 'replace')
             offset = len(text)
             if len(self.text) != offset:
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to