diff options
author | Gregory P. Smith <greg@mad-scientist.com> | 2007-08-24 05:11:38 (GMT) |
---|---|---|
committer | Gregory P. Smith <greg@mad-scientist.com> | 2007-08-24 05:11:38 (GMT) |
commit | 1042a4d71966b597141537d247e1d1e69e42d906 (patch) | |
tree | f20ed94fdd365f942c9499e8cb1c4fde30676835 /Lib | |
parent | daa6f254c6cf5acad6fb56bc9f360ec26407b409 (diff) | |
download | cpython-1042a4d71966b597141537d247e1d1e69e42d906.zip cpython-1042a4d71966b597141537d247e1d1e69e42d906.tar.gz cpython-1042a4d71966b597141537d247e1d1e69e42d906.tar.bz2 |
Fix bug 1725856.
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/bsddb/__init__.py | 4 | ||||
-rwxr-xr-x | Lib/test/test_bsddb.py | 16 |
2 files changed, 20 insertions, 0 deletions
diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py index cf32668..7eb625c 100644 --- a/Lib/bsddb/__init__.py +++ b/Lib/bsddb/__init__.py @@ -274,12 +274,16 @@ class _DBWithCursor(_iter_mixin): def first(self): self._checkOpen() + # fix 1725856: don't needlessly try to restore our cursor position + self.saved_dbc_key = None self._checkCursor() rv = _DeadlockWrap(self.dbc.first) return rv def last(self): self._checkOpen() + # fix 1725856: don't needlessly try to restore our cursor position + self.saved_dbc_key = None self._checkCursor() rv = _DeadlockWrap(self.dbc.last) return rv diff --git a/Lib/test/test_bsddb.py b/Lib/test/test_bsddb.py index fbe855f..acd4972 100755 --- a/Lib/test/test_bsddb.py +++ b/Lib/test/test_bsddb.py @@ -127,6 +127,22 @@ class TestBSDDB(unittest.TestCase): items.append(self.f.previous()) 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): self.assertEqual(self.f.set_location('e'), ('e', self.d['e'])) |