[issue9636] {'key': 'value'}[b'key'] raises a BytesWarning

Mark Dickinson report at bugs.python.org
Thu Aug 19 16:02:21 CEST 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

> The warning in the dict case is especially important

It's worth noting that this warning is dependent on hash() producing the same values for 'equivalent' bytes and str instances.  This seems a bit fragile, and is something that could potentially change in the future---with bytes and str comparing unequal, there's no reason for the hashes to correspond.

(It might even make sense to deliberately change the hash for either  bytes or str so that it doesn't match the other, just to expose any bugs that rely on the hashes being identical.)

----------
nosy: +mark.dickinson

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9636>
_______________________________________


More information about the Python-bugs-list mailing list