summaryrefslogtreecommitdiffstats
path: root/Modules/_bsddb.c
diff options
context:
space:
mode:
Diffstat (limited to 'Modules/_bsddb.c')
-rw-r--r--Modules/_bsddb.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index 0ef797c..c6efa1c 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -265,6 +265,7 @@ typedef struct {
typedef struct {
PyObject_HEAD
DB_TXN* txn;
+ PyObject *env;
#ifdef HAVE_WEAKREF
PyObject *in_weakreflist; /* List of weak references */
#endif
@@ -921,6 +922,8 @@ newDBTxnObject(DBEnvObject* myenv, DB_TXN *parent, int flags)
DBTxnObject* self = PyObject_New(DBTxnObject, &DBTxn_Type);
if (self == NULL)
return NULL;
+ Py_INCREF(myenv);
+ self->env = (PyObject*)myenv;
#ifdef HAVE_WEAKREF
self->in_weakreflist = NULL;
#endif
@@ -931,11 +934,10 @@ newDBTxnObject(DBEnvObject* myenv, DB_TXN *parent, int flags)
#else
err = txn_begin(myenv->db_env, parent, &(self->txn), flags);
#endif
- /* TODO add a weakref(self) to the self->myenvobj->open_child_weakrefs
- * list so that a DBEnv can refuse to close without aborting any open
- * open DBTxns and closing any open DBs first. */
MYDB_END_ALLOW_THREADS;
if (makeDBError(err)) {
+ Py_DECREF(self->env);
+ PyObject_Del(self);
self = NULL;
}
return self;
@@ -966,6 +968,7 @@ DBTxn_dealloc(DBTxnObject* self)
}
#endif
+ Py_DECREF(self->env);
PyObject_Del(self);
}