Closed jamadden closed 5 years ago
We can convert the non-deterministic failure to a deterministic failure by adding 1
to the list of sizes in test_random
.
There are two ways of fixing the bug:
encode_deltas
always return RiceCode
instances (might this break users? do we need to bump the major version to 5?)decode_deltas
accept a list.I'm not myself a user of zope.index.text.ricecode, so I don't know what's best.
Actually, we can't return empty RiceCode
instances -- that makes decode_deltas
fail with an IndexError: list index out of range.
It's starting to look like it'd be better to make decode_deltas handle empty deltas.
zope.index.text.ricecode.encode_deltas(a_list)
returns a tuple(start, deltas)
. Usuallydeltas
is an instance ofzope.index.text.ricecode.RiceCode
, but whenlen(a_list) == 1)
,deltas
is a simple[]
.This is an awkward API that causes problems: the inverse
decode_deltas(start, deltas)
method requiresdeltas
to be aRiceCode
and fails if you pass in an empty list.This case can be seen in the zope.index's own testsuite, where
test_random
can fail non-deterministically.Originally discovered in
https://github.com/zopefoundation/zope.index/pull/21#issuecomment-443264249