Chris Angelico wrote:
> So the only way would be to call len(), and if it fails, fall back
> on
> the "expected 2" form. And I'm not sure if that would be worthwhile,
> given that it's going to have to run arbitrary code just for the sake
> of the error message.

I did address these:

> 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.

Is there anyone who thinks it's acceptable to run `len()` on arbitrary objects 
for an error message? Assuming 'no', then the length is only shown if the type 
is exactly one of list, tuple, str, etc. where we know __len__ exists and is 
safe. Alternatively, instead of checking the type, we could check if `__len__` 
itself belongs to a safe set, if we want to include e.g. subclasses of `list`.
_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-le...@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/python-ideas@python.org/message/3MSHVDWV2YPCYLNPTWXAADUBTFNUCXTB/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to