]> granicus.if.org Git - python/commitdiff
- pybsddb Bug #1527939: bsddb module DBEnv dbremove and dbrename
authorGregory P. Smith <greg@mad-scientist.com>
Fri, 28 Jul 2006 01:35:25 +0000 (01:35 +0000)
committerGregory P. Smith <greg@mad-scientist.com>
Fri, 28 Jul 2006 01:35:25 +0000 (01:35 +0000)
  methods now allow their database parameter to be None as the
  sleepycat API allows.

Also adds an appropriate test case for DBEnv.dbrename and dbremove.

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

index 0ae873208035d038c640a7cc276461b72ed0eee8..25e0b6b974653d2f27dd1da8dba8c7b6fa0f8bfc 100644 (file)
@@ -562,6 +562,9 @@ class BasicTestCase(unittest.TestCase):
         num = d.truncate()
         assert num == 0, "truncate on empty DB returned nonzero (%r)" % (num,)
 
+    #----------------------------------------
+
+
 #----------------------------------------------------------------------
 
 
@@ -583,18 +586,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 294b159f84742be1bf5a1d264a374a3b160f01b3..663203ba420fd9ce78823234f6192cb1649ac255 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -128,6 +128,10 @@ Extension Modules
 - Because of a misspelled preprocessor symbol, ctypes was always
   compiled without thread support; this is now fixed.
 
+- pybsddb Bug #1527939: bsddb module DBEnv dbremove and dbrename
+  methods now allow their database parameter to be None as the
+  sleepycat API allows.
+
 Tests
 -----
 
index 9e302bcdfc38cd44f680cc8490afa3771637a5c9..b39e6f2884b4a504bbec0b8bbcdfaa87e5b7d5f4 100644 (file)
@@ -98,7 +98,7 @@
 #error "eek! DBVER can't handle minor versions > 9"
 #endif
 
-#define PY_BSDDB_VERSION "4.4.4"
+#define PY_BSDDB_VERSION "4.4.5"
 static char *rcs_id = "$Id$";
 
 
@@ -3876,7 +3876,7 @@ DBEnv_dbremove(DBEnvObject* self, PyObject* args, PyObject* kwargs)
     static 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;
     }
@@ -3904,7 +3904,7 @@ DBEnv_dbrename(DBEnvObject* self, PyObject* args, PyObject* kwargs)
     static 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;
     }