Nick Coghlan added the comment:

As Raymond notes, this is a fairly harmless quirk - it changes a SyntaxError to 
an iterable length dependent ValueError:

>>> () = []
  File "<stdin>", line 1
SyntaxError: can't assign to ()
>>> [] = ()
>>> [] = [1]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: too many values to unpack (expected 0)

I only found out about this after being puzzled when a typo in a live demo at 
PyCon 2015 failed to fail as I expected after seeing the presenter type a "[]" 
into the LHS of an assignment instead of the intended "_".

Removing the data dependence to make the assignment fail immediately (even if 
never tested against a non-empty iterable) would involve making the handling of 
List_kind match that of Tuple_kind in the switch statement that eryksun quoted.

I don't think it's an urgent fix, but if someone wanted to fix it (including a 
new test), I think it would be a reasonable contribution to accept.

----------
nosy: +ncoghlan

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue23275>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to