Commit 2509cc6d 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 047c5946
...@@ -1530,7 +1530,7 @@ class TransactionIterator(object): ...@@ -1530,7 +1530,7 @@ class TransactionIterator(object):
def next(self): def next(self):
if self._ended: if self._ended:
raise ZODB.interfaces.StorageStopIteration() raise StopIteration()
if self._iid < 0: if self._iid < 0:
raise ClientDisconnected("Disconnected iterator") raise ClientDisconnected("Disconnected iterator")
...@@ -1541,7 +1541,7 @@ class TransactionIterator(object): ...@@ -1541,7 +1541,7 @@ class TransactionIterator(object):
# disposed it. # disposed it.
self._ended = True self._ended = True
self._storage._forget_iterator(self._iid) self._storage._forget_iterator(self._iid)
raise ZODB.interfaces.StorageStopIteration() raise StopIteration()
return ClientStorageTransactionInformation( return ClientStorageTransactionInformation(
self._storage, self, *tx_data) self._storage, self, *tx_data)
...@@ -1582,13 +1582,13 @@ class RecordIterator(object): ...@@ -1582,13 +1582,13 @@ class RecordIterator(object):
if self._completed: if self._completed:
# We finished iteration once already and the server can't know # We finished iteration once already and the server can't know
# about the iteration anymore. # about the iteration anymore.
raise ZODB.interfaces.StorageStopIteration() raise StopIteration()
item = self._storage._server.iterator_record_next(self._riid) item = self._storage._server.iterator_record_next(self._riid)
if item is None: if item is None:
# The iterator is exhausted, and the server has already # The iterator is exhausted, and the server has already
# disposed it. # disposed it.
self._completed = True self._completed = True
raise ZODB.interfaces.StorageStopIteration() raise StopIteration()
return ZODB.BaseStorage.DataRecord(*item) return ZODB.BaseStorage.DataRecord(*item)
......
...@@ -229,13 +229,9 @@ class IteratorDeepCompare: ...@@ -229,13 +229,9 @@ class IteratorDeepCompare:
# meaning they were the same length. # meaning they were the same length.
# Additionally, check that we're backwards compatible to the # Additionally, check that we're backwards compatible to the
# IndexError we used to raise before. # IndexError we used to raise before.
self.assertRaises(IndexError, itxn1.next)
self.assertRaises(IndexError, itxn2.next)
self.assertRaises(StopIteration, itxn1.next) self.assertRaises(StopIteration, itxn1.next)
self.assertRaises(StopIteration, itxn2.next) self.assertRaises(StopIteration, itxn2.next)
# Make sure ther are no more records left in txn1 and txn2, meaning # Make sure ther are no more records left in txn1 and txn2, meaning
# they were the same length # they were the same length
self.assertRaises(IndexError, iter1.next)
self.assertRaises(IndexError, iter2.next)
self.assertRaises(StopIteration, iter1.next) self.assertRaises(StopIteration, iter1.next)
self.assertRaises(StopIteration, iter2.next) self.assertRaises(StopIteration, iter2.next)
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
############################################################################## ##############################################################################
import ZODB.MappingStorage import ZODB.MappingStorage
import unittest import unittest
import ZODB.tests.hexstorage
from ZODB.tests import ( from ZODB.tests import (
...@@ -53,8 +54,16 @@ class MappingStorageTests( ...@@ -53,8 +54,16 @@ class MappingStorageTests(
pass # we don't support undo yet pass # we don't support undo yet
checkUndoZombie = checkLoadBeforeUndo checkUndoZombie = checkLoadBeforeUndo
class MappingStorageHexTests(MappingStorageTests):
def setUp(self):
StorageTestBase.StorageTestBase.setUp(self, )
self._storage = ZODB.tests.hexstorage.HexStorage(
ZODB.MappingStorage.MappingStorage())
def test_suite(): def test_suite():
suite = unittest.makeSuite(MappingStorageTests, 'check') suite = unittest.makeSuite(MappingStorageTests, 'check')
suite = unittest.makeSuite(MappingStorageHexTests, 'check')
return suite return suite
if __name__ == "__main__": 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