[ZODB-Dev] Storage iterators and IndexError

Hanno Schlichting hanno at hannosch.eu
Sat May 15 06:52:23 EDT 2010


On Fri, May 14, 2010 at 8:43 PM, Jim Fulton <jim at zope.com> wrote:
> There's a test for storage iterators that verifies that they raise
> a special exception that extends StopIteration and IndexError.
> This makes storage iterators a bit harder to implement than
> necessary.
>
> Does anyone know of a reason why we should have to raise
> a special error that raises IndexErrors?

Not really. It sounds like it's trying to do both new-style iterators
(via __iter__ / next / StopIteration) and old-style iteration (via
__getitem__ / IndexError) at once.

>From http://docs.python.org/reference/datamodel.html about
"object.__getitem__(self, key)": Note for loops expect that an
IndexError will be raised for illegal indexes to allow proper
detection of the end of the sequence.

Hanno


More information about the ZODB-Dev mailing list