diff options
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_grammar.py | 4 | ||||
-rw-r--r-- | Lib/test/test_syntax.py | 38 |
2 files changed, 9 insertions, 33 deletions
diff --git a/Lib/test/test_grammar.py b/Lib/test/test_grammar.py index 3f1e1fa51fd..3ea4e47ca50 100644 --- a/Lib/test/test_grammar.py +++ b/Lib/test/test_grammar.py @@ -1375,6 +1375,8 @@ class GrammarTests(unittest.TestCase): try: 1/0 except (EOFError, TypeError, ZeroDivisionError): pass try: 1/0 + except EOFError, TypeError, ZeroDivisionError: pass + try: 1/0 except (EOFError, TypeError, ZeroDivisionError) as msg: pass try: pass finally: pass @@ -1398,6 +1400,8 @@ class GrammarTests(unittest.TestCase): try: 1/0 except* (EOFError, TypeError, ZeroDivisionError): pass try: 1/0 + except* EOFError, TypeError, ZeroDivisionError: pass + try: 1/0 except* (EOFError, TypeError, ZeroDivisionError) as msg: pass try: pass finally: pass diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index d2950cf48ab..2c87b145254 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -1667,28 +1667,14 @@ Make sure that the old "raise X, Y[, Z]" form is gone: SyntaxError: invalid syntax Check that an multiple exception types with missing parentheses -raise a custom exception - - >>> try: - ... pass - ... except A, B: - ... pass - Traceback (most recent call last): - SyntaxError: multiple exception types must be parenthesized - - >>> try: - ... pass - ... except A, B, C: - ... pass - Traceback (most recent call last): - SyntaxError: multiple exception types must be parenthesized +raise a custom exception only when using 'as' >>> try: ... pass ... except A, B, C as blech: ... pass Traceback (most recent call last): - SyntaxError: multiple exception types must be parenthesized + SyntaxError: multiple exception types must be parenthesized when using 'as' >>> try: ... pass @@ -1697,29 +1683,15 @@ raise a custom exception ... finally: ... pass Traceback (most recent call last): - SyntaxError: multiple exception types must be parenthesized + SyntaxError: multiple exception types must be parenthesized when using 'as' >>> try: ... pass - ... except* A, B: - ... pass - Traceback (most recent call last): - SyntaxError: multiple exception types must be parenthesized - - >>> try: - ... pass - ... except* A, B, C: - ... pass - Traceback (most recent call last): - SyntaxError: multiple exception types must be parenthesized - - >>> try: - ... pass ... except* A, B, C as blech: ... pass Traceback (most recent call last): - SyntaxError: multiple exception types must be parenthesized + SyntaxError: multiple exception types must be parenthesized when using 'as' >>> try: ... pass @@ -1728,7 +1700,7 @@ raise a custom exception ... finally: ... pass Traceback (most recent call last): - SyntaxError: multiple exception types must be parenthesized + SyntaxError: multiple exception types must be parenthesized when using 'as' Custom exception for 'except*' without an exception type |