From fea6059476c8e6acc043db51119765ba956114c0 Mon Sep 17 00:00:00 2001 From: Georg Brandl Date: Mon, 20 Feb 2006 20:29:56 +0000 Subject: Bug #1210377: close bsddb cursor correctly after NotFoundError. --- Lib/bsddb/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py index cfe554b..be8e577 100644 --- a/Lib/bsddb/__init__.py +++ b/Lib/bsddb/__init__.py @@ -112,7 +112,10 @@ class _iter_mixin(UserDict.DictMixin): def iteritems(self): try: - cur = self._make_iter_cursor() + try: + cur = self._make_iter_cursor() + except AttributeError: + return # FIXME-20031102-greg: race condition. cursor could # be closed by another thread before this call. @@ -189,7 +192,10 @@ class _DBWithCursor(_iter_mixin): c = self.dbc self.dbc = None if save: - self.saved_dbc_key = c.current(0,0,0)[0] + try: + self.saved_dbc_key = c.current(0,0,0)[0] + except db.DBError: + pass c.close() del c for cref in self._cursor_refs.values(): -- cgit v0.12