]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
- pybsddb Bug #1527939: bsddb module DBEnv dbremove and dbrename
authorGregory P. Smith <greg@mad-scientist.com>
Fri, 28 Jul 2006 03:16:53 +0000 (03:16 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Fri, 28 Jul 2006 03:16:53 +0000 (03:16 +0000)
  methods now allow their database parameter to be None as the
  sleepycat API allows.

also adds a testcase.

backport of trunk commit 50889 to 2.4.

Lib/bsddb/test/test_basics.py
Misc/NEWS
Modules/_bsddb.c

index 155705df1d9e03b62d896d2021c3412c1c3cbde9..b7395addbca662f8fa2ab9481f7ed4655faf4b53 100644 (file)
@@ -555,6 +555,9 @@ class BasicTestCase(unittest.TestCase):
         num = d.truncate()
         assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
 
+    #----------------------------------------
+
+
 #----------------------------------------------------------------------
 
 
@@ -576,18 +579,40 @@ class BasicHashWithThreadFlagTestCase(BasicTestCase):
     dbopenflags = db.DB_THREAD
 
 
-class BasicBTreeWithEnvTestCase(BasicTestCase):
-    dbtype = db.DB_BTREE
+class BasicWithEnvTestCase(BasicTestCase):
     dbopenflags = db.DB_THREAD
     useEnv = 1
     envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
 
+    #----------------------------------------
+
+    def test07_EnvRemoveAndRename(self):
+        if not self.env:
+            return
+
+        if verbose:
+            print '\n', '-=' * 30
+            print "Running %s.test07_EnvRemoveAndRename..." % self.__class__.__name__
+
+        # can't rename or remove an open DB
+        self.d.close()
+
+        newname = self.filename + '.renamed'
+        self.env.dbrename(self.filename, None, newname)
+        self.env.dbremove(newname)
+
+    # dbremove and dbrename are in 4.1 and later
+    if db.version() < (4,1):
+        del test07_EnvRemoveAndRename
 
-class BasicHashWithEnvTestCase(BasicTestCase):
+    #----------------------------------------
+
+class BasicBTreeWithEnvTestCase(BasicWithEnvTestCase):
+    dbtype = db.DB_BTREE
+
+
+class BasicHashWithEnvTestCase(BasicWithEnvTestCase):
     dbtype = db.DB_HASH
-    dbopenflags = db.DB_THREAD
-    useEnv = 1
-    envflags = db.DB_THREAD | db.DB_INIT_MPOOL | db.DB_INIT_LOCK
 
 
 #----------------------------------------------------------------------
index 48c9f16c3b7b02c3dae8f24f565c679c9e937371..9531c610d063d6aa94b9cf30e4a0d9111b8166e2 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -60,6 +60,9 @@ Extension Modules
   return correct results.  It could previously incorrectly return 0 in some
   cases.  Fixes SF bug 1493322 (pybsddb bug 1184012).
 
+- pybsddb Bug #1527939: bsddb module DBEnv dbremove and dbrename
+  methods now allow their database parameter to be None as the
+  sleepycat API allows.
 
 Library
 -------
index b3707e91b66de7467bd48dfbee166d0822b61d7d..1d3badf7b32ae89e4306ac8ea4a69d4614515a11 100644 (file)
@@ -97,7 +97,7 @@
 #error "eek! DBVER can't handle minor versions > 9"
 #endif
 
-#define PY_BSDDB_VERSION "4.3.0.2"
+#define PY_BSDDB_VERSION "4.3.0.3"
 static char *rcs_id = "$Id$";
 
 
@@ -3587,7 +3587,7 @@ DBEnv_dbremove(DBEnvObject* self, PyObject* args, PyObject* kwargs)
     DB_TXN *txn = NULL;
     char* kwnames[] = { "file", "database", "txn", "flags", NULL };
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "ss|Oi:dbremove", kwnames,
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "s|zOi:dbremove", kwnames,
                &file, &database, &txnobj, &flags)) {
        return NULL;
     }
@@ -3614,7 +3614,7 @@ DBEnv_dbrename(DBEnvObject* self, PyObject* args, PyObject* kwargs)
     DB_TXN *txn = NULL;
     char* kwnames[] = { "file", "database", "newname", "txn", "flags", NULL };
 
-    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "sss|Oi:dbrename", kwnames,
+    if (!PyArg_ParseTupleAndKeywords(args, kwargs, "szs|Oi:dbrename", kwnames,
                &file, &database, &newname, &txnobj, &flags)) {
        return NULL;
     }