Commit 5da866f4 authored by Jim Fulton's avatar Jim Fulton

Deprecated ZODB.interfaces.StorageStopIteration. Storage

iterator implementations should just raise StopIteration, which
means they can now be implemented as generators.
parent e6679a5e
......@@ -1530,7 +1530,7 @@ class TransactionIterator(object):
def next(self):
if self._ended:
raise ZODB.interfaces.StorageStopIteration()
raise StopIteration()
if self._iid < 0:
raise ClientDisconnected("Disconnected iterator")
......@@ -1541,7 +1541,7 @@ class TransactionIterator(object):
# disposed it.
self._ended = True
self._storage._forget_iterator(self._iid)
raise ZODB.interfaces.StorageStopIteration()
raise StopIteration()
return ClientStorageTransactionInformation(
self._storage, self, *tx_data)
......@@ -1582,13 +1582,13 @@ class RecordIterator(object):
if self._completed:
# We finished iteration once already and the server can't know
# about the iteration anymore.
raise ZODB.interfaces.StorageStopIteration()
raise StopIteration()
item = self._storage._server.iterator_record_next(self._riid)
if item is None:
# The iterator is exhausted, and the server has already
# disposed it.
self._completed = True
raise ZODB.interfaces.StorageStopIteration()
raise StopIteration()
return ZODB.BaseStorage.DataRecord(*item)
......
......@@ -229,13 +229,9 @@ class IteratorDeepCompare:
# meaning they were the same length.
# Additionally, check that we're backwards compatible to the
# IndexError we used to raise before.
self.assertRaises(IndexError, itxn1.next)
self.assertRaises(IndexError, itxn2.next)
self.assertRaises(StopIteration, itxn1.next)
self.assertRaises(StopIteration, itxn2.next)
# Make sure ther are no more records left in txn1 and txn2, meaning
# they were the same length
self.assertRaises(IndexError, iter1.next)
self.assertRaises(IndexError, iter2.next)
self.assertRaises(StopIteration, iter1.next)
self.assertRaises(StopIteration, iter2.next)
......@@ -13,6 +13,7 @@
##############################################################################
import ZODB.MappingStorage
import unittest
import ZODB.tests.hexstorage
from ZODB.tests import (
......@@ -53,8 +54,16 @@ class MappingStorageTests(
pass # we don't support undo yet
checkUndoZombie = checkLoadBeforeUndo
class MappingStorageHexTests(MappingStorageTests):
def setUp(self):
StorageTestBase.StorageTestBase.setUp(self, )
self._storage = ZODB.tests.hexstorage.HexStorage(
ZODB.MappingStorage.MappingStorage())
def test_suite():
suite = unittest.makeSuite(MappingStorageTests, 'check')
suite = unittest.makeSuite(MappingStorageHexTests, 'check')
return suite
if __name__ == "__main__":
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment