[pypy-svn] r61425 - in pypy/trunk/pypy/interpreter: astcompiler/test pyparser
fijal at codespeak.net
fijal at codespeak.net
Wed Jan 28 16:31:35 CET 2009
Author: fijal
Date: Wed Jan 28 16:31:32 2009
New Revision: 61425
Modified:
pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py
pypy/trunk/pypy/interpreter/pyparser/asthelper.py
Log:
another convoluted layer of logic, for catching
x(y=3, 4)
Modified: pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py
==============================================================================
--- pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py (original)
+++ pypy/trunk/pypy/interpreter/astcompiler/test/test_compiler.py Wed Jan 28 16:31:32 2009
@@ -657,4 +657,9 @@
raise Exception("DID NOT RAISE")
def test_kwargs_last(self):
- py.test.raises(SyntaxError, "int(base=10, '2')")
+ py.test.raises(SyntaxError, self.simple_test, "int(base=10, '2')",
+ None, None)
+
+ def test_crap_after_starargs(self):
+ source = "call(*args, *args)"
+ py.test.raises(SyntaxError, self.simple_test, source, None, None)
Modified: pypy/trunk/pypy/interpreter/pyparser/asthelper.py
==============================================================================
--- pypy/trunk/pypy/interpreter/pyparser/asthelper.py (original)
+++ pypy/trunk/pypy/interpreter/pyparser/asthelper.py Wed Jan 28 16:31:32 2009
@@ -68,6 +68,21 @@
if not isinstance(cur_token, TokenObject):
index += 1
if not building_kw:
+ # this logic states that it'll be triggered once we built a kw
+ # already and 1. we're at then end -or-
+ # next token is a comma
+ if kw_built:
+ if index == l:
+ raise SyntaxError("non-keyword arg after keyword arg",
+ cur_token.lineno, 0)
+ token = tokens[index]
+ if (isinstance(token, TokenObject) and
+ token.name == builder.parser.tokens['COMMA']):
+ raise SyntaxError("non-keyword arg after keyword arg",
+ cur_token.lineno, 0)
+
+ # XXX where to get col num?
+
arguments.append(cur_token)
else:
last_token = arguments.pop()
More information about the Pypy-commit
mailing list