8000 bpo-40067: Improve error messages for multiple star expressions in as… · python/cpython@cb6534e · GitHub
[go: up one dir, main page]

Skip to content
8000

Commit cb6534e

Browse files
furkanonderisidenticalpablogsal
authored
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>
1 parent 5c3cda0 commit cb6534e

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

Lib/test/test_unpack_ex.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -308,12 +308,17 @@
308308
>>> a, *b, c, *d, e = range(10) # doctest:+ELLIPSIS
309309
Traceback (most recent call last):
310310
...
311-
SyntaxError: two starred expressions in assignment
311+
SyntaxError: multiple starred expressions in assignment
312312
313313
>>> [*b, *c] = range(10) # doctest:+ELLIPSIS
314314
Traceback (most recent call last):
315315
...
316-
SyntaxError: two starred expressions in assignment
316+
SyntaxError: multiple starred expressions in assignment
317+
318+
>>> a,*b,*c,*d = range(4) # doctest:+ELLIPSIS
319+
Traceback (most recent call last):
320+
...
321+
SyntaxError: multiple starred expressions in assignment
317322
318323
>>> *a = range(10) # doctest:+ELLIPSIS
319324
Traceback (most recent call last):

Misc/ACKS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,7 @@ Jeffrey Ollie
12361236
Adam Olsen
12371237
Bryan Olson
12381238
Grant Olson
1239+
Furkan Onder
12391240
Koray Oner
12401241
Piet van Oostrum
12411242
Tomas Oppelstrup
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Improve the error message for multiple star expressions in an assignment.
2+
Patch by Furkan Onder

Python/compile.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3708,7 +3708,7 @@ assignment_helper(struct compiler *c, asdl_seq *elts)
37083708
}
37093709
else if (elt->kind == Starred_kind) {
37103710
return compiler_error(c,
3711-
"two starred expressions in assignment");
3711+
"multiple starred expressions in assignment");
37123712
}
37133713
}
37143714
if (!seen_star) {

0 commit comments

Comments
 (0)
0