Currently this code:

d = {"key": "value"}
for key, value in d:
    pass

produces this error:

ValueError: too many values to unpack (expected 2)

I suggest that the error message should also have:

1. The name of the type of the unpacked value
2. The length of the unpacked value, if it exists and (to not execute arbitrary 
__len__ implementations) if the type belongs to a safe subset, e.g. only 
builtin types.

Then the error message could be:

ValueError: too many values to unpack (expected 2, found 3) from object of type 
str
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/C6QEAEEAELUHMLB23OBRSQK2UYU3AF5O/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to