mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
bpo-45292: [PEP-654] add except* (GH-29581)
This commit is contained in:
parent
850aefc2c6
commit
d60457a667
34 changed files with 7070 additions and 3332 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue