Author: Sebastian Pawlu? <[email protected]>
Branch: py3.3
Changeset: r76085:e9662ca0f43f
Date: 2015-02-23 16:52 +0100
http://bitbucket.org/pypy/pypy/changeset/e9662ca0f43f/
Log: (xando, mjacob) fixing recent changes in pyparser (b3ad7de8410c)
diff --git a/lib-python/3/test/test_compile.py
b/lib-python/3/test/test_compile.py
--- a/lib-python/3/test/test_compile.py
+++ b/lib-python/3/test/test_compile.py
@@ -3,6 +3,7 @@
import _ast
import types
from test import support
+from test.support import check_impl_detail
class TestSpecifics(unittest.TestCase):
@@ -466,7 +467,9 @@
def test_bad_single_statement(self):
self.assertInvalidSingle('1\n2')
- self.assertInvalidSingle('def f(): pass')
+ if check_impl_detail():
+ # it's a single statment in PyPy
+ self.assertInvalidSingle('def f(): pass')
self.assertInvalidSingle('a = 13\nb = 187')
self.assertInvalidSingle('del x\ndel y')
self.assertInvalidSingle('f()\ng()')
diff --git a/pypy/interpreter/pyparser/pyparse.py
b/pypy/interpreter/pyparser/pyparse.py
--- a/pypy/interpreter/pyparser/pyparse.py
+++ b/pypy/interpreter/pyparser/pyparse.py
@@ -3,6 +3,7 @@
from pypy.interpreter.astcompiler import consts
from rpython.rlib import rstring
+
def recode_to_utf8(space, bytes, encoding):
if encoding == 'utf-8':
return bytes
@@ -167,12 +168,15 @@
compile_info.flags |= newflags
self.grammar = pygram.python_grammar
tokens_stream = iter(tokens)
+
for tp, value, lineno, column, line in tokens_stream:
if self.add_token(tp, value, lineno, column, line):
break
if compile_info.mode == 'single':
for tp, value, lineno, column, line in tokens_stream:
+ if tp == pygram.tokens.ENDMARKER:
+ break
if tp == pygram.tokens.NEWLINE:
continue
diff --git a/pypy/interpreter/pyparser/test/test_pyparse.py
b/pypy/interpreter/pyparser/test/test_pyparse.py
--- a/pypy/interpreter/pyparser/test/test_pyparse.py
+++ b/pypy/interpreter/pyparser/test/test_pyparse.py
@@ -154,7 +154,6 @@
def test_bad_single_statement(self):
py.test.raises(SyntaxError, self.parse, '1\n2', "single")
- py.test.raises(SyntaxError, self.parse, 'def f(): pass', "single")
py.test.raises(SyntaxError, self.parse, 'a = 13\nb = 187', "single")
py.test.raises(SyntaxError, self.parse, 'del x\ndel y', "single")
py.test.raises(SyntaxError, self.parse, 'f()\ng()', "single")
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit