diff options
author | Lysandros Nikolaou <lisandrosnik@gmail.com> | 2022-09-17 19:09:28 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-09-17 10:09:28 -0700 |
commit | 7e36abbb7815b14777c207dba0fe6fcd41d6d37a (patch) | |
tree | 4329d4d070261c451d9e9ccbd4d3a8833522c6c8 /Lib/test/test_syntax.py | |
parent | 78359b1d45608439f8e03b8e86174fe7b04d3e08 (diff) | |
download | cpython-git-7e36abbb7815b14777c207dba0fe6fcd41d6d37a.tar.gz |
gh-91210: Improve error message when non-default param follows default (GH-95933)
- Improve error message when parameter without a default follows one with a default
- Show same error message when positional-only params precede the default/non-default sequence
Diffstat (limited to 'Lib/test/test_syntax.py')
-rw-r--r-- | Lib/test/test_syntax.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py index ae1066924b..69a86231e2 100644 --- a/Lib/test/test_syntax.py +++ b/Lib/test/test_syntax.py @@ -334,7 +334,12 @@ From ast_for_arguments(): >>> def f(x, y=1, z): ... pass Traceback (most recent call last): -SyntaxError: non-default argument follows default argument +SyntaxError: parameter without a default follows parameter with a default + +>>> def f(x, /, y=1, z): +... pass +Traceback (most recent call last): +SyntaxError: parameter without a default follows parameter with a default >>> def f(x, None): ... pass @@ -555,6 +560,14 @@ SyntaxError: expected default value expression Traceback (most recent call last): SyntaxError: expected default value expression +>>> lambda a,d=3,c: None +Traceback (most recent call last): +SyntaxError: parameter without a default follows parameter with a default + +>>> lambda a,/,d=3,c: None +Traceback (most recent call last): +SyntaxError: parameter without a default follows parameter with a default + >>> import ast; ast.parse(''' ... def f( ... *, # type: int |