summaryrefslogtreecommitdiff
path: root/Lib/test/test_grammar.py
diff options
context:
space:
mode:
authorGuido van Rossum <guido@python.org>2020-05-14 19:01:14 -0700
committerGuido van Rossum <guido@python.org>2020-05-14 19:01:14 -0700
commitf93a54c48fc1644012aa0d4ee3887c1d121ac40e (patch)
tree189c841245d15318e5895638105bdbc532cbcdf5 /Lib/test/test_grammar.py
parent31641ff0e4b18c8d002d019f4506f0e8fb446983 (diff)
parent16ab07063cb564c1937714bd39d6915172f005b5 (diff)
downloadcpython-git-fix-traceback-syntax-error.tar.gz
Merge branch 'master' into fix-traceback-syntax-errorfix-traceback-syntax-error
Diffstat (limited to 'Lib/test/test_grammar.py')
-rw-r--r--Lib/test/test_grammar.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py
index 02ba8a8b15..e1a402e2b4 100644
--- a/Lib/test/test_grammar.py
+++ b/Lib/test/test_grammar.py
@@ -1279,7 +1279,7 @@ class GrammarTests(unittest.TestCase):
def test_try(self):
### try_stmt: 'try' ':' suite (except_clause ':' suite)+ ['else' ':' suite]
### | 'try' ':' suite 'finally' ':' suite
- ### except_clause: 'except' [expr ['as' expr]]
+ ### except_clause: 'except' [expr ['as' NAME]]
try:
1/0
except ZeroDivisionError:
@@ -1297,6 +1297,9 @@ class GrammarTests(unittest.TestCase):
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")
def test_suite(self):
# simple_stmt | NEWLINE INDENT NEWLINE* (stmt NEWLINE*)+ DEDENT