[pypy-svn] r75090 - in pypy/branch/fast-forward/pypy/interpreter: astcompiler/test pyparser/data
benjamin at codespeak.net
benjamin at codespeak.net
Fri Jun 4 01:05:42 CEST 2010
Author: benjamin
Date: Fri Jun 4 01:05:41 2010
New Revision: 75090
Modified:
pypy/branch/fast-forward/pypy/interpreter/astcompiler/test/test_astbuilder.py
pypy/branch/fast-forward/pypy/interpreter/pyparser/data/Grammar2.7
Log:
implement 'as' in except clauses
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 4 01:05:41 2010
@@ -405,6 +405,15 @@
assert isinstance(h2.type, ast.Name)
assert h2.name is None
assert isinstance(h2.body[0], ast.Pass)
+ tr = self.get_first_stmt("try: x\nexcept Exc as a: 5\nexcept F: pass")
+ assert len(tr.handlers) == 2
+ h1, h2 = tr.handlers
+ assert isinstance(h1.type, ast.Name)
+ assert isinstance(h1.name, ast.Name)
+ assert isinstance(h1.body[0].value, ast.Num)
+ assert isinstance(h2.type, ast.Name)
+ assert h2.name is None
+ assert isinstance(h2.body[0], ast.Pass)
tr = self.get_first_stmt("try: x\nexcept: 4\nfinally: pass")
assert isinstance(tr, ast.TryFinally)
assert len(tr.finalbody) == 1
Modified: pypy/branch/fast-forward/pypy/interpreter/pyparser/data/Grammar2.7
==============================================================================
--- pypy/branch/fast-forward/pypy/interpreter/pyparser/data/Grammar2.7 (original)
+++ pypy/branch/fast-forward/pypy/interpreter/pyparser/data/Grammar2.7 Fri Jun 4 01:05:41 2010
@@ -85,7 +85,7 @@
with_stmt: 'with' test [ with_var ] ':' suite
with_var: ('as' | NAME) expr
# NB compile.c makes sure that the default except clause is last
-except_clause: 'except' [test [',' test]]
+except_clause: 'except' [test [('as' | ',') test]]
suite: simple_stmt | NEWLINE INDENT stmt+ DEDENT
# Backward compatibility cruft to support:
More information about the Pypy-commit
mailing list