[New-bugs-announce] [issue24370] OrderedDict behavior is unclear with misbehaving keys.

Eric Snow report at bugs.python.org
Wed Jun 3 05:01:20 CEST 2015


New submission from Eric Snow:

How well does OrderedDict need to behave in the face of keys with unstable hashes (e.g. define __hash__ with varying results across calls)?  I would expect the behavior to be undefined (though non-crashing).  Here's an example of a misbehaving key:

    class Key:
        def __hash__(self):
            return randrange(10000)

FWIW, dict does pretty well even with bad keys.  The pure Python OrderedDict does okay.

----------
assignee: eric.snow
components: Library (Lib)
messages: 244727
nosy: eric.snow, rhettinger
priority: normal
severity: normal
stage: needs patch
status: open
title: OrderedDict behavior is unclear with misbehaving keys.
type: behavior
versions: Python 3.5, Python 3.6

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


More information about the New-bugs-announce mailing list