Replace bare except by specific exception.

svn: r16606
This commit is contained in:
Michiel Nauta 2011-02-11 18:29:15 +00:00
parent 52b136b305
commit 0eb166615b

View File

@ -1378,13 +1378,16 @@ class DbBsddb(DbBsddbRead, DbWriteBase, UpdateCallback):
person.get_primary_name().serialize())) person.get_primary_name().serialize()))
try: try:
cursor = self.surnames.cursor(txn=self.txn) cursor = self.surnames.cursor(txn=self.txn)
cursor.set(name) cursor_position = cursor.set(name)
if cursor.count() == 1: if cursor_position is not None and cursor.count() == 1:
i = bisect.bisect(self.surname_list, name) i = bisect.bisect(self.surname_list, name)
if 0 <= i-1 < len(self.surname_list): if 0 <= i-1 < len(self.surname_list):
del self.surname_list[i-1] del self.surname_list[i-1]
except: except db.DBError, err:
pass if str(err) == "(0, 'DB object has been closed')":
pass # A batch transaction closes the surnames db table.
else:
raise
finally: finally:
if 'cursor' in locals(): if 'cursor' in locals():
cursor.close() cursor.close()