From cb6534e1a8833b3f20bd88f52cf62a003426e855 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Furkan=20=C3=96nder?= Date: Thu, 26 Mar 2020 04:54:31 +0300 Subject: [PATCH] bpo-40067: Improve error messages for multiple star expressions in assignments (GH-19168) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Batuhan Taşkaya Co-Authored-By: Pablo Galindo --- Lib/test/test_unpack_ex.py | 9 +++++++-- Misc/ACKS | 1 + .../2020-03-25-20-34-01.bpo-40067.0bFda2.rst | 2 ++ Python/compile.c | 2 +- 4 files changed, 11 insertions(+), 3 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2020-03-25-20-34-01.bpo-40067.0bFda2.rst diff --git a/Lib/test/test_unpack_ex.py b/Lib/test/test_unpack_ex.py index 46f70c2b98c..e333af78f1d 100644 --- a/Lib/test/test_unpack_ex.py +++ b/Lib/test/test_unpack_ex.py @@ -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): diff --git a/Misc/ACKS b/Misc/ACKS index 129db952d88..a4db5a54703 100644 --- a/Misc/ACKS +++ b/Misc/ACKS @@ -1236,6 +1236,7 @@ Jeffrey Ollie Adam Olsen Bryan Olson Grant Olson +Furkan Onder Koray Oner Piet van Oostrum Tomas Oppelstrup diff --git a/Misc/NEWS.d/next/Core and Builtins/2020-03-25-20-34-01.bpo-40067.0bFda2.rst b/Misc/NEWS.d/next/Core and Builtins/2020-03-25-20-34-01.bpo-40067.0bFda2.rst new file mode 100644 index 00000000000..2e1b20d2937 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2020-03-25-20-34-01.bpo-40067.0bFda2.rst @@ -0,0 +1,2 @@ +Improve the error message for multiple star expressions in an assignment. +Patch by Furkan Onder diff --git a/Python/compile.c b/Python/compile.c index 0b3926c436c..01700e0e78c 100644 --- a/Python/compile.c +++ b/Python/compile.c @@ -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) {