summaryrefslogtreecommitdiff
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index b6c4574656..a2460add4c 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -1419,6 +1419,30 @@ class GrammarTests(unittest.TestCase):
compile("try:\n pass\nexcept Exception as a.b:\n pass", "?", "exec")
compile("try:\n pass\nexcept Exception as a[b]:\n pass", "?", "exec")
+ def test_try_star(self):
+ ### try_stmt: 'try': suite (except_star_clause : suite) + ['else' ':' suite]
+ ### except_star_clause: 'except*' expr ['as' NAME]
+ try:
+ 1/0
+ except* ZeroDivisionError:
+ pass
+ else:
+ pass
+ try: 1/0
+ except* EOFError: pass
+ except* ZeroDivisionError as msg: pass
+ else: pass
+ try: 1/0
+ except* (EOFError, TypeError, ZeroDivisionError): pass
+ try: 1/0
+ except* (EOFError, TypeError, ZeroDivisionError) as msg: pass
+ try: pass
+ finally: pass
+ with self.assertRaises(SyntaxError):
+ compile("try:\n pass\nexcept* Exception as a.b:\n pass", "?", "exec")
+ compile("try:\n pass\nexcept* Exception as a[b]:\n pass", "?", "exec")
+ compile("try:\n pass\nexcept*:\n pass", "?", "exec")
+
def test_suite(self):
# simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT
if 1: pass