Kaydet (Commit) 1042a4d7 authored tarafından Gregory P. Smith's avatar Gregory P. Smith

Fix bug 1725856.

üst daa6f254
...@@ -274,12 +274,16 @@ class _DBWithCursor(_iter_mixin): ...@@ -274,12 +274,16 @@ class _DBWithCursor(_iter_mixin):
def first(self): def first(self):
self._checkOpen() self._checkOpen()
# fix 1725856: don't needlessly try to restore our cursor position
self.saved_dbc_key = None
self._checkCursor() self._checkCursor()
rv = _DeadlockWrap(self.dbc.first) rv = _DeadlockWrap(self.dbc.first)
return rv return rv
def last(self): def last(self):
self._checkOpen() self._checkOpen()
# fix 1725856: don't needlessly try to restore our cursor position
self.saved_dbc_key = None
self._checkCursor() self._checkCursor()
rv = _DeadlockWrap(self.dbc.last) rv = _DeadlockWrap(self.dbc.last)
return rv return rv
......
...@@ -127,6 +127,22 @@ class TestBSDDB(unittest.TestCase): ...@@ -127,6 +127,22 @@ class TestBSDDB(unittest.TestCase):
items.append(self.f.previous()) items.append(self.f.previous())
self.assertSetEquals(items, self.d.items()) self.assertSetEquals(items, self.d.items())
def test_first_while_deleting(self):
# Test for bug 1725856
self.assert_(len(self.d) >= 2, "test requires >=2 items")
for _ in self.d:
key = self.f.first()[0]
del self.f[key]
self.assertEqual([], self.f.items(), "expected empty db after test")
def test_last_while_deleting(self):
# Test for bug 1725856's evil twin
self.assert_(len(self.d) >= 2, "test requires >=2 items")
for _ in self.d:
key = self.f.last()[0]
del self.f[key]
self.assertEqual([], self.f.items(), "expected empty db after test")
def test_set_location(self): def test_set_location(self):
self.assertEqual(self.f.set_location('e'), ('e', self.d['e'])) self.assertEqual(self.f.set_location('e'), ('e', self.d['e']))
......
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