mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Make close() identical to __del__() for a dumbdbm database. Make
closing idempotent (it used to raise a nuisance exception on the 2nd close attempt). Bugfix candidate? Probably, but arguable.
This commit is contained in:
parent
4a4296ec29
commit
7a6c733c3b
3 changed files with 15 additions and 5 deletions
|
@ -92,6 +92,9 @@ class _Database(UserDict.DictMixin):
|
|||
# CAUTION: It's vital that _commit() succeed, and _commit() can
|
||||
# be called from __del__(). Therefore we must never reference a
|
||||
# global in this routine.
|
||||
if self._index is None:
|
||||
return # nothing to do
|
||||
|
||||
try:
|
||||
self._os.unlink(self._bakfile)
|
||||
except self._os.error:
|
||||
|
@ -204,12 +207,9 @@ class _Database(UserDict.DictMixin):
|
|||
|
||||
def close(self):
|
||||
self._commit()
|
||||
self._index = None
|
||||
self._datfile = self._dirfile = self._bakfile = None
|
||||
self._index = self._datfile = self._dirfile = self._bakfile = None
|
||||
|
||||
def __del__(self):
|
||||
if self._index is not None:
|
||||
self._commit()
|
||||
__del__ = close
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue