[pypy-svn] r79870 - in pypy/trunk/pypy/interpreter/pyparser: . test
arigo at codespeak.net
arigo at codespeak.net
Tue Dec 7 17:23:42 CET 2010
Author: arigo
Date: Tue Dec 7 17:23:41 2010
New Revision: 79870
Modified:
pypy/trunk/pypy/interpreter/pyparser/pytokenizer.py
pypy/trunk/pypy/interpreter/pyparser/test/test_pyparse.py
Log:
In the report of these SyntaxErrors, shift the caret one place to the
right in order to point exactly to the start of the string or the
parenthesis that is never closed.
Modified: pypy/trunk/pypy/interpreter/pyparser/pytokenizer.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyparser/pytokenizer.py (original)
+++ pypy/trunk/pypy/interpreter/pyparser/pytokenizer.py Tue Dec 7 17:23:41 2010
@@ -94,7 +94,7 @@
if contstr:
if not line:
raise TokenError("EOF while scanning triple-quoted string",
- strstart[2], strstart[0], strstart[1],
+ strstart[2], strstart[0], strstart[1]+1,
token_list)
endmatch = endDFA.recognize(line)
if endmatch >= 0:
@@ -151,6 +151,7 @@
start = 0
if parenlev > 0:
lnum, start, line = parenlevstart
+ start += 1
raise TokenError("EOF in multi-line statement", line,
lnum, start, token_list)
continued = 0
@@ -237,7 +238,7 @@
start = pos
if start<max and line[start] in single_quoted:
raise TokenError("EOL while scanning single-quoted string",
- line, lnum, start, token_list)
+ line, lnum, start+1, token_list)
tok = (tokens.ERRORTOKEN, line[pos], lnum, pos, line)
token_list.append(tok)
last_comment = ''
Modified: pypy/trunk/pypy/interpreter/pyparser/test/test_pyparse.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyparser/test/test_pyparse.py (original)
+++ pypy/trunk/pypy/interpreter/pyparser/test/test_pyparse.py Tue Dec 7 17:23:41 2010
@@ -67,17 +67,17 @@
exc = py.test.raises(SyntaxError, parse, "x = \"blah\n\n\n").value
assert exc.msg == "EOL while scanning single-quoted string"
assert exc.lineno == 1
- assert exc.offset == 4
+ assert exc.offset == 5
exc = py.test.raises(SyntaxError, parse, "x = '''\n\n\n").value
assert exc.msg == "EOF while scanning triple-quoted string"
assert exc.lineno == 1
- assert exc.offset == 4
+ assert exc.offset == 5
for input in ("())", "(()", "((", "))"):
py.test.raises(SyntaxError, parse, input)
exc = py.test.raises(SyntaxError, parse, "x = (\n\n(),\n(),").value
assert exc.msg == "EOF in multi-line statement"
assert exc.lineno == 1
- assert exc.offset == 4
+ assert exc.offset == 5
def test_is(self):
self.parse("x is y")
More information about the Pypy-commit
mailing list