bpo-40067: Improve error messages for multiple star expressions in assignments (GH-19168)

Co-Authored-By: Batuhan Taşkaya <isidentical@gmail.com>
Co-Authored-By: Pablo Galindo <Pablogsal@gmail.com>
This commit is contained in:
Furkan Önder 2020-03-26 04:54:31 +03:00 committed by GitHub
parent 5c3cda0d1a
commit cb6534e1a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 11 additions and 3 deletions

View File

@ -308,12 +308,17 @@ Now some general starred expressions (all fail).
>>> a, *b, c, *d, e = range(10) # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: two starred expressions in assignment
SyntaxError: multiple starred expressions in assignment
>>> [*b, *c] = range(10) # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: two starred expressions in assignment
SyntaxError: multiple starred expressions in assignment
>>> a,*b,*c,*d = range(4) # doctest:+ELLIPSIS
Traceback (most recent call last):
...
SyntaxError: multiple starred expressions in assignment
>>> *a = range(10) # doctest:+ELLIPSIS
Traceback (most recent call last):

View File

@ -1236,6 +1236,7 @@ Jeffrey Ollie
Adam Olsen
Bryan Olson
Grant Olson
Furkan Onder
Koray Oner
Piet van Oostrum
Tomas Oppelstrup

View File

@ -0,0 +1,2 @@
Improve the error message for multiple star expressions in an assignment.
Patch by Furkan Onder

View File

@ -3708,7 +3708,7 @@ assignment_helper(struct compiler *c, asdl_seq *elts)
}
else if (elt->kind == Starred_kind) {
return compiler_error(c,
"two starred expressions in assignment");
"multiple starred expressions in assignment");
}
}
if (!seen_star) {