Author ncoghlan
Recipients Cesar.Kawakami, Devin Jeanpierre, Kyle.Buzsaki, eryksun, ezio.melotti, martin.panter, ncoghlan, r.david.murray, rhettinger
Date 2015-04-19.02:47:53
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1429411673.53.0.0924127573429.issue23275@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2015-04-19 02:47:53ncoghlansetrecipients: + ncoghlan, rhettinger, Devin Jeanpierre, ezio.melotti, r.david.murray, martin.panter, eryksun, Cesar.Kawakami, Kyle.Buzsaki
2015-04-19 02:47:53ncoghlansetmessageid: <1429411673.53.0.0924127573429.issue23275@psf.upfronthosting.co.za>
2015-04-19 02:47:53ncoghlanlinkissue23275 messages
2015-04-19 02:47:53ncoghlancreate