diff options
author | Pablo Galindo Salgado <Pablogsal@gmail.com> | 2021-11-20 18:27:40 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-11-20 18:27:40 (GMT) |
commit | 7a1d9325287a39528b795b1e8037146777abfe3e (patch) | |
tree | 52120380f57212078ce780146a9b09a02ec74ca6 /Lib/test/test_syntax.py | |
parent | 985233914504c73f14a23af1c68a3709079e6913 (diff) | |
download | cpython-7a1d9325287a39528b795b1e8037146777abfe3e.zip cpython-7a1d9325287a39528b795b1e8037146777abfe3e.tar.gz cpython-7a1d9325287a39528b795b1e8037146777abfe3e.tar.bz2 |
bpo-45450: Improve syntax error for parenthesized arguments (GH-28906)
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index f41df8c..28414ba 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -909,6 +909,44 @@ Missing parens after function definition Traceback (most recent call last): SyntaxError: expected '(' +Parenthesized arguments in function definitions + + >>> def f(x, (y, z), w): + ... pass + Traceback (most recent call last): + SyntaxError: Function parameters cannot be parenthesized + + >>> def f((x, y, z, w)): + ... pass + Traceback (most recent call last): + SyntaxError: Function parameters cannot be parenthesized + + >>> def f(x, (y, z, w)): + ... pass + Traceback (most recent call last): + SyntaxError: Function parameters cannot be parenthesized + + >>> def f((x, y, z), w): + ... pass + Traceback (most recent call last): + SyntaxError: Function parameters cannot be parenthesized + + >>> lambda x, (y, z), w: None + Traceback (most recent call last): + SyntaxError: Lambda expression parameters cannot be parenthesized + + >>> lambda (x, y, z, w): None + Traceback (most recent call last): + SyntaxError: Lambda expression parameters cannot be parenthesized + + >>> lambda x, (y, z, w): None + Traceback (most recent call last): + SyntaxError: Lambda expression parameters cannot be parenthesized + + >>> lambda (x, y, z), w: None + Traceback (most recent call last): + SyntaxError: Lambda expression parameters cannot be parenthesized + Custom error messages for try blocks that are not followed by except/finally >>> try: |