[Python-checkins] r54090 - in sandbox/trunk/2to3: Grammar.txt tests/test_grammar.py
collin.winter
python-checkins at python.org
Fri Mar 2 21:33:02 CET 2007
Author: collin.winter
Date: Fri Mar 2 21:33:02 2007
New Revision: 54090
Modified:
sandbox/trunk/2to3/Grammar.txt
sandbox/trunk/2to3/tests/test_grammar.py
Log:
Add support for parsing Py3k's 'raise ... from ...' statement.
Modified: sandbox/trunk/2to3/Grammar.txt
==============================================================================
--- sandbox/trunk/2to3/Grammar.txt (original)
+++ sandbox/trunk/2to3/Grammar.txt Fri Mar 2 21:33:02 2007
@@ -66,7 +66,7 @@
continue_stmt: 'continue'
return_stmt: 'return' [testlist]
yield_stmt: yield_expr
-raise_stmt: 'raise' [test [',' test [',' test]]]
+raise_stmt: 'raise' [test ['from' test | ',' test [',' test]]]
import_stmt: import_name | import_from
import_name: 'import' dotted_as_names
import_from: ('from' ('.'* dotted_name | '.'+)
Modified: sandbox/trunk/2to3/tests/test_grammar.py
==============================================================================
--- sandbox/trunk/2to3/tests/test_grammar.py (original)
+++ sandbox/trunk/2to3/tests/test_grammar.py Fri Mar 2 21:33:02 2007
@@ -33,6 +33,35 @@
pass
+class TestRaiseChanges(GrammarTest):
+ def test_2x_style_1(self):
+ self.validate("raise")
+
+ def test_2x_style_2(self):
+ self.validate("raise E, V")
+
+ def test_2x_style_3(self):
+ self.validate("raise E, V, T")
+
+ def test_2x_style_invalid_1(self):
+ self.invalid_syntax("raise E, V, T, Z")
+
+ def test_3x_style(self):
+ self.validate("raise E1 from E2")
+
+ def test_3x_style_invalid_1(self):
+ self.invalid_syntax("raise E, V from E1")
+
+ def test_3x_style_invalid_2(self):
+ self.invalid_syntax("raise E from E1, E2")
+
+ def test_3x_style_invalid_3(self):
+ self.invalid_syntax("raise from E1, E2")
+
+ def test_3x_style_invalid_4(self):
+ self.invalid_syntax("raise E from")
+
+
# Adapated from Python 3's Lib/test/test_grammar.py:GrammarTests.testFuncdef
class TestFunctionAnnotations(GrammarTest):
def test_1(self):
More information about the Python-checkins
mailing list