Index: Modules/_bsddb.c =================================================================== --- Modules/_bsddb.c (révision 66475) +++ Modules/_bsddb.c (copie de travail) @@ -1071,6 +1071,7 @@ if (self == NULL) return NULL; + self->db_env = NULL; self->closed = 1; self->flags = flags; self->moduleFlags.getReturnsNone = DEFAULT_GET_RETURNS_NONE; @@ -1099,7 +1100,7 @@ } /* Forward declaration */ -static PyObject *DBEnv_close_internal(DBEnvObject* self, int flags); +static PyObject *DBEnv_close_internal(DBEnvObject* self, int flags, int check_error); static void DBEnv_dealloc(DBEnvObject* self) @@ -1107,7 +1108,8 @@ PyObject *dummy; if (self->db_env) { - dummy=DBEnv_close_internal(self,0); + /* ignore errors at exit */ + dummy=DBEnv_close_internal(self,0,0); Py_XDECREF(dummy); } @@ -3967,7 +3969,7 @@ static PyObject* -DBEnv_close_internal(DBEnvObject* self, int flags) +DBEnv_close_internal(DBEnvObject* self, int flags, int check_error) { PyObject *dummy; int err; @@ -3991,8 +3993,10 @@ /* after calling DBEnv->close, regardless of error, this DBEnv * may not be accessed again (Berkeley DB docs). */ self->db_env = NULL; + if (check_error) { RETURN_IF_ERR(); } + } RETURN_NONE(); } @@ -4003,7 +4007,7 @@ if (!PyArg_ParseTuple(args, "|i:close", &flags)) return NULL; - return DBEnv_close_internal(self,flags); + return DBEnv_close_internal(self,flags,1); }