bpo-40618: Disallow invalid targets in augassign and except clauses (GH-20083)
This commit fixes the new parser to disallow invalid targets in the
following scenarios:
- Augmented assignments must only accept a single target (Name,
Attribute or Subscript), but no tuples or lists.
- `except` clauses should only accept a single `Name` as a target.
Co-authored-by: Pablo Galindo <Pablogsal@gmail.com>
diff --git a/Lib/test/test_syntax.py b/Lib/test/test_syntax.py
index 06636ae..a3a1015 100644
--- a/Lib/test/test_syntax.py
+++ b/Lib/test/test_syntax.py
@@ -129,6 +129,18 @@
Traceback (most recent call last):
SyntaxError: cannot assign to conditional expression
+>>> a, b += 1, 2
+Traceback (most recent call last):
+SyntaxError: invalid syntax
+
+>>> (a, b) += 1, 2
+Traceback (most recent call last):
+SyntaxError: cannot assign to tuple
+
+>>> [a, b] += 1, 2
+Traceback (most recent call last):
+SyntaxError: cannot assign to list
+
From compiler_complex_args():
>>> def f(None=1):