[pypy-commit] pypy py3k: Nonsense occurs in SyntaxErrors with continuation lines (ending in '\').
arigo
pypy.commits at gmail.com
Wed Oct 5 16:49:53 EDT 2016
Author: Armin Rigo <arigo at tunes.org>
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:
More information about the pypy-commit
mailing list