diff --git a/Doc/whatsnew/3.5.rst b/Doc/whatsnew/3.5.rst
--- a/Doc/whatsnew/3.5.rst
+++ b/Doc/whatsnew/3.5.rst
@@ -222,16 +222,19 @@ Some smaller changes made to the core Py
* Added the ``'namereplace'`` error handlers. The ``'backslashreplace'``
error handlers now works with decoding and translating.
(Contributed by Serhiy Storchaka in :issue:`19676` and :issue:`22286`.)
* The :option:`-b` option now affects comparisons of :class:`bytes` with
:class:`int`. (Contributed by Serhiy Storchaka in :issue:`23681`)
+* ``() = []`` is now a valid assignment. Previously, it raised a
+ :exc:`SyntaxError`.
+
New Modules
===========
.. _whatsnew-zipapp:
zipapp
------
diff --git a/Lib/test/test_tuple.py b/Lib/test/test_tuple.py
--- a/Lib/test/test_tuple.py
+++ b/Lib/test/test_tuple.py
@@ -211,10 +211,16 @@ class TupleTest(seq_tests.CommonTest):
def test_lexicographic_ordering(self):
# Issue 21100
a = self.type2test([1, 2])
b = self.type2test([1, 2, 0])
c = self.type2test([1, 3])
self.assertLess(a, b)
self.assertLess(b, c)
+ def test_empty_tuple_assignment(self):
+ () = []
+ with self.assertRaisesRegex(ValueError,
+ 'too many values to unpack \(expected 0\)'):
+ () = [0]
+
if __name__ == "__main__":
unittest.main()
diff --git a/Python/ast.c b/Python/ast.c
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -913,23 +913,18 @@ set_context(struct compiling *c, expr_ty
}
e->v.Name.ctx = ctx;
break;
case List_kind:
e->v.List.ctx = ctx;
s = e->v.List.elts;
break;
case Tuple_kind:
- if (asdl_seq_LEN(e->v.Tuple.elts)) {
- e->v.Tuple.ctx = ctx;
- s = e->v.Tuple.elts;
- }
- else {
- expr_name = "()";
- }
+ e->v.Tuple.ctx = ctx;
+ s = e->v.Tuple.elts;
break;
case Lambda_kind:
expr_name = "lambda";
break;
case Call_kind:
expr_name = "function call";
break;
case BoolOp_kind: