[pypy-svn] r75601 - in pypy/branch/fast-forward/pypy/interpreter/astcompiler: . test
benjamin at codespeak.net
benjamin at codespeak.net
Fri Jun 25 17:11:06 CEST 2010
Author: benjamin
Date: Fri Jun 25 17:11:05 2010
New Revision: 75601
Modified:
pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py
pypy/branch/fast-forward/pypy/interpreter/astcompiler/test/test_astbuilder.py
Log:
obscure syntax case
Modified: pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py (original)
+++ pypy/branch/fast-forward/pypy/interpreter/astcompiler/astbuilder.py Fri Jun 25 17:11:05 2010
@@ -538,6 +538,8 @@
argument = arguments_node.children[i]
arg_type = argument.type
if arg_type == syms.fpdef:
+ parenthesized = False
+ complex_args = False
while True:
if i + 1 < child_count and \
arguments_node.children[i + 1].type == tokens.EQUAL:
@@ -546,13 +548,19 @@
i += 2
have_default = True
elif have_default:
- msg = "non-default argument follows default argument"
+ if parenthesized and not complex_args:
+ msg = "parenthesized arg with default"
+ else:
+ msg = ("non-default argument follows default "
+ "argument")
self.error(msg, arguments_node)
if len(argument.children) == 3:
sub_arg = argument.children[1]
if len(sub_arg.children) != 1:
+ complex_args = True
args.append(self.handle_arg_unpacking(sub_arg))
else:
+ parenthesized = True
argument = sub_arg.children[0]
continue
if argument.children[0].type == tokens.NAME:
Modified: pypy/branch/fast-forward/pypy/interpreter/astcompiler/test/test_astbuilder.py
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/astcompiler/test/test_astbuilder.py (original)
+++ pypy/branch/fast-forward/pypy/interpreter/astcompiler/test/test_astbuilder.py Fri Jun 25 17:11:05 2010
@@ -580,6 +580,9 @@
input = "def f(a=b, c): pass"
exc = py.test.raises(SyntaxError, self.get_ast, input).value
assert exc.msg == "non-default argument follows default argument"
+ input = "def f((x)=23): pass"
+ exc = py.test.raises(SyntaxError, self.get_ast, input).value
+ assert exc.msg == "parenthesized arg with default"
def test_decorators(self):
to_examine = (("def f(): pass", ast.FunctionDef),
More information about the Pypy-commit
mailing list