[Python-Dev] Dicts are broken Was: unicode hell/mixing str and unicode asdictionarykeys
Ralf Schmitt
ralf at brainbot.com
Tue Aug 8 10:12:59 CEST 2006
Martin v. Löwis wrote:
> M.-A. Lemburg schrieb:
>> Hiding programmer errors is not making life easier in the
>> long run, so I'm -1 on having the equality comparison return
>> False.
>
> There is no error to hide here. The objects are inequal, period.
And in the case of dicts it hides errors randomly...
>
>> Instead we should generate a warning in Python 2.5 and introduce
>> the exception in Python 2.6.
>
> A warning about what? That you can't put byte string and Unicode
> strings into the same dictionary (as keys)? Next we start not allowing
> to put numbers and strings into the same dictionary, because there
> is no conversion defined between them?
A warning that an exception has been ignored while adding a key to a
dict, I guess. I'd see keep those dict changes, this is where real
programmer errors are hidden.
>> I disagree with this part.
>>
>> Failure to decode a string doesn't imply inequality.
>
> If the failure is "these bytes don't have a meaningful character
> interpretation", then the bytes are *clearly* not equal to
> some character string.
One could also think of a "magic encoding", which decodes non-ascii
strings to None, making them compare unequal to any unicode string.
More information about the Python-Dev
mailing list