[tahoe-lafs-trac-stream] [Tahoe-LAFS] #2899: ValueOrderedDict throws IndexError when given equal non-identical keys
Tahoe-LAFS
trac at tahoe-lafs.org
Thu Aug 10 01:37:54 UTC 2017
#2899: ValueOrderedDict throws IndexError when given equal non-identical keys
--------------------+---------------------------
Reporter: warner | Owner:
Type: defect | Status: new
Priority: minor | Milestone: undecided
Component: code | Version: 1.12.1
Keywords: | Launchpad Bug:
--------------------+---------------------------
{{{
from allmydata.util.dictutil import ValueOrderedDict
a = (1,2)
b = (1,2)
d = ValueOrderedDict()
d[a] = 1
d[b] = 1
d[b] = 2
}}}
gives:
{{{
File ".../src/allmydata/util/dictutil.py", line 509, in __setitem__
while (self.l[i][0] is not oldval) or (self.l[i][1] is not key):
IndexError: list index out of range
}}}
I found this while trying to improve the test coverage, to exercise the `i
+= 1` statement inside that `while` loop. I think the only way to reach it
is to have keys which are equal but not identical. Python doesn't
(currently? always?) consolidate equivalent tuples (although I think it'd
be allowed to), which is one way to hit this case.
--
Ticket URL: <https://tahoe-lafs.org/trac/tahoe-lafs/ticket/2899>
Tahoe-LAFS <https://Tahoe-LAFS.org>
secure decentralized storage
More information about the tahoe-lafs-trac-stream
mailing list