]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-43149: Correct the syntax error message for multiple exception types (GH-25996...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Sun, 9 May 2021 21:13:50 +0000 (14:13 -0700)
committerGitHub <noreply@github.com>
Sun, 9 May 2021 21:13:50 +0000 (22:13 +0100)
Automerge-Triggered-By: GH:pablogsal
(cherry picked from commit 6692dc1ca99fb34a19d0a4b93cf8e10619490001)

Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
Doc/whatsnew/3.10.rst
Grammar/python.gram
Lib/test/test_syntax.py
Misc/NEWS.d/next/Core and Builtins/2021-05-08-17-18-37.bpo-43149.Kp5FxD.rst [new file with mode: 0644]
Parser/parser.c

index cfc560e1f4435f87a92875d5e23c89838e45cdad..2c6569fccd624d4f5030cde53925aaa754caa80d 100644 (file)
@@ -248,7 +248,7 @@ have been incorporated. Some of the most notable ones:
           File "<stdin>", line 3
             except NotEnoughScienceError, NotEnoughResourcesError:
                    ^
-        SyntaxError: exception group must be parenthesized
+        SyntaxError: multiple exception types must be parenthesized
 
     (Contributed by Pablo Galindo in :issue:`43149`)
 
index 2f553c6d390c7159b2b8151cbdbf397077148b45..6b815ab0c518d493ffcf57764278cd9219847a13 100644 (file)
@@ -956,7 +956,7 @@ invalid_try_stmt:
         RAISE_INDENTATION_ERROR("expected an indented block after 'try' statement on line %d", a->lineno) }
 invalid_except_stmt:
     | 'except' a=expression ',' expressions ['as' NAME ] ':' {
-        RAISE_SYNTAX_ERROR_STARTING_FROM(a, "exception group must be parenthesized") }
+        RAISE_SYNTAX_ERROR_STARTING_FROM(a, "multiple exception types must be parenthesized") }
     | a='except' expression ['as' NAME ] NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
     | a='except' NEWLINE { RAISE_SYNTAX_ERROR("expected ':'") }
 invalid_finally_stmt:
index 9799697b87d3b107d324e2aae0e0e76caf597597..58407212b492f7df810e5ab278fda9205e000ec5 100644 (file)
@@ -1068,7 +1068,7 @@ Make sure that the old "raise X, Y[, Z]" form is gone:
      ...
    SyntaxError: invalid syntax
 
-Check that an exception group with missing parentheses
+Check that an multiple exception types with missing parentheses
 raise a custom exception
 
    >>> try:
@@ -1076,21 +1076,21 @@ raise a custom exception
    ... except A, B:
    ...   pass
    Traceback (most recent call last):
-   SyntaxError: exception group must be parenthesized
+   SyntaxError: multiple exception types must be parenthesized
 
    >>> try:
    ...   pass
    ... except A, B, C:
    ...   pass
    Traceback (most recent call last):
-   SyntaxError: exception group must be parenthesized
+   SyntaxError: multiple exception types must be parenthesized
 
    >>> try:
    ...   pass
    ... except A, B, C as blech:
    ...   pass
    Traceback (most recent call last):
-   SyntaxError: exception group must be parenthesized
+   SyntaxError: multiple exception types must be parenthesized
 
    >>> try:
    ...   pass
@@ -1099,7 +1099,7 @@ raise a custom exception
    ... finally:
    ...   pass
    Traceback (most recent call last):
-   SyntaxError: exception group must be parenthesized
+   SyntaxError: multiple exception types must be parenthesized
 
 
 >>> f(a=23, a=234)
diff --git a/Misc/NEWS.d/next/Core and Builtins/2021-05-08-17-18-37.bpo-43149.Kp5FxD.rst b/Misc/NEWS.d/next/Core and Builtins/2021-05-08-17-18-37.bpo-43149.Kp5FxD.rst
new file mode 100644 (file)
index 0000000..cc1983e
--- /dev/null
@@ -0,0 +1,2 @@
+Corrent the syntax error message regarding multiple exception types to not
+refer to "exception groups". Patch by Pablo Galindo
index 6958963dfa39cfab3a0052734d50aeba29b1aa39..2ca628b59ba869161ebc948a7107ee655b74a8f1 100644 (file)
@@ -19978,7 +19978,7 @@ invalid_except_stmt_rule(Parser *p)
         )
         {
             D(fprintf(stderr, "%*c+ invalid_except_stmt[%d-%d]: %s succeeded!\n", p->level, ' ', _mark, p->mark, "'except' expression ',' expressions ['as' NAME] ':'"));
-            _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "exception group must be parenthesized" );
+            _res = RAISE_SYNTAX_ERROR_STARTING_FROM ( a , "multiple exception types must be parenthesized" );
             if (_res == NULL && PyErr_Occurred()) {
                 p->error_indicator = 1;
                 D(p->level--);