~ubuntu-branches/ubuntu/quantal/python2.7/quantal-proposed

« back to all changes in this revision

Viewing changes to debian/patches/db5.1.diff

  • Committer: Package Import Robot
  • Author(s): Matthias Klose
  • Date: 2012-01-06 21:57:07 UTC
  • Revision ID: package-import@ubuntu.com-20120106215707-da7ef71vawoka4yy
Tags: 2.7.2-9ubuntu1
* Update to 20120105, taken from the 2.7 branch.
* Test build using db5.1.
* Overwrite some lintian warnings:
  - The -dbg interpreters are not unusual.
  - The -gdb.py files don't need a python dependency.
  - lintian can't handle a whatis entry starting with one word on the line.
* Fix test failures related to distutils debian installation layout.
* Add build-arch/build-indep targets.
* Regenerate Setup and Makefiles after correcting Setup.local.
* profiled-build.diff: Pass PY_CFLAGS instead of CFLAGS for the profiled
  build.
* Pass dpkg-buildflags to the build process, and build third party
  extensions with these flags.
* Add support to build using -flto (and -g1) on some architectures.
* Disable pgo builds for some architectures (for now, keep just
  amd64 armel armhf i386 powerpc ppc64).
* Build-depend on libgdbm-dev to build and run the gdbm tests.
* Build-depend on xvfb to run the tkinter tests.
* python2.7: Provide python2.7-argparse and python-argparse.
* Don't run test_threading on mips/mipsel.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
diff --git a/setup.py b/setup.py
 
2
index 6c512a5..e6850ff 100644
 
3
--- a/setup.py
 
4
+++ b/setup.py
 
5
@@ -776,7 +776,7 @@ class PyBuildExt(build_ext):
 
6
         # a release.  Most open source OSes come with one or more
 
7
         # versions of BerkeleyDB already installed.
 
8
 
 
9
-        max_db_ver = (4, 8)
 
10
+        max_db_ver = (5, 1)
 
11
         min_db_ver = (4, 1)
 
12
         db_setup_debug = False   # verbose debug prints from this script?
 
13
 
 
14
@@ -798,7 +798,11 @@ class PyBuildExt(build_ext):
 
15
             return True
 
16
 
 
17
         def gen_db_minor_ver_nums(major):
 
18
-            if major == 4:
 
19
+            if major == 5:
 
20
+                for x in range(max_db_ver[1]+1):
 
21
+                    if allow_db_ver((5, x)):
 
22
+                        yield x
 
23
+            elif major == 4:
 
24
                 for x in range(max_db_ver[1]+1):
 
25
                     if allow_db_ver((4, x)):
 
26
                         yield x
 
27
diff --git a/Lib/bsddb/__init__.py b/Lib/bsddb/__init__.py
 
28
index ed4deea..eec3412 100644
 
29
--- a/Lib/bsddb/__init__.py
 
30
+++ b/Lib/bsddb/__init__.py
 
31
@@ -33,7 +33,7 @@
 
32
 #----------------------------------------------------------------------
 
33
 
 
34
 
 
35
-"""Support for Berkeley DB 4.1 through 4.8 with a simple interface.
 
36
+"""Support for Berkeley DB 4.2 through 5.1 with a simple interface.
 
37
 
 
38
 For the full featured object oriented interface use the bsddb.db module
 
39
 instead.  It mirrors the Oracle Berkeley DB C API.
 
40
diff --git a/Lib/bsddb/test/test_all.py b/Lib/bsddb/test/test_all.py
 
41
index e9fe618..6a25f4a 100644
 
42
--- a/Lib/bsddb/test/test_all.py
 
43
+++ b/Lib/bsddb/test/test_all.py
 
44
@@ -484,6 +484,8 @@ def print_versions():
 
45
     print '-=' * 38
 
46
     print db.DB_VERSION_STRING
 
47
     print 'bsddb.db.version():   %s' % (db.version(), )
 
48
+    if db.version() >= (5, 0) :
 
49
+        print 'bsddb.db.full_version(): %s' %repr(db.full_version())
 
50
     print 'bsddb.db.__version__: %s' % db.__version__
 
51
     print 'bsddb.db.cvsid:       %s' % db.cvsid
 
52
 
 
53
@@ -528,7 +530,8 @@ def get_new_database_path() :
 
54
 
 
55
 # This path can be overriden via "set_test_path_prefix()".
 
56
 import os, os.path
 
57
-get_new_path.prefix=os.path.join(os.sep,"tmp","z-Berkeley_DB")
 
58
+get_new_path.prefix=os.path.join(os.environ.get("TMPDIR",
 
59
+    os.path.join(os.sep,"tmp")), "z-Berkeley_DB")
 
60
 get_new_path.num=0
 
61
 
 
62
 def get_test_path_prefix() :
 
63
diff --git a/Lib/bsddb/test/test_associate.py b/Lib/bsddb/test/test_associate.py
 
64
index 7a49e11..9df4fb3 100644
 
65
--- a/Lib/bsddb/test/test_associate.py
 
66
+++ b/Lib/bsddb/test/test_associate.py
 
67
@@ -76,6 +76,11 @@ musicdata = {
 
68
 #----------------------------------------------------------------------
 
69
 
 
70
 class AssociateErrorTestCase(unittest.TestCase):
 
71
+    import sys
 
72
+    if sys.version_info < (2, 4) :
 
73
+        def assertTrue(self, expr, msg=None):
 
74
+            self.failUnless(expr,msg=msg)
 
75
+
 
76
     def setUp(self):
 
77
         self.filename = self.__class__.__name__ + '.db'
 
78
         self.homeDir = get_new_environment_path()
 
79
@@ -120,6 +125,11 @@ class AssociateErrorTestCase(unittest.TestCase):
 
80
 
 
81
 
 
82
 class AssociateTestCase(unittest.TestCase):
 
83
+    import sys
 
84
+    if sys.version_info < (2, 4) :
 
85
+        def assertTrue(self, expr, msg=None):
 
86
+            self.failUnless(expr,msg=msg)
 
87
+
 
88
     keytype = ''
 
89
     envFlags = 0
 
90
     dbFlags = 0
 
91
diff --git a/Lib/bsddb/test/test_basics.py b/Lib/bsddb/test/test_basics.py
 
92
index 4d43390..4096e00 100644
 
93
--- a/Lib/bsddb/test/test_basics.py
 
94
+++ b/Lib/bsddb/test/test_basics.py
 
95
@@ -74,7 +74,6 @@ class BasicTestCase(unittest.TestCase):
 
96
         # create and open the DB
 
97
         self.d = db.DB(self.env)
 
98
         if not self.useEnv :
 
99
-            if db.version() >= (4, 2) :
 
100
                 self.d.set_cachesize(*self.cachesize)
 
101
                 cachesize = self.d.get_cachesize()
 
102
                 self.assertEqual(cachesize[0], self.cachesize[0])
 
103
@@ -792,7 +791,6 @@ class BasicTransactionTestCase(BasicTestCase):
 
104
         for log in logs:
 
105
             if verbose:
 
106
                 print 'log file: ' + log
 
107
-        if db.version() >= (4,2):
 
108
             logs = self.env.log_archive(db.DB_ARCH_REMOVE)
 
109
             self.assertTrue(not logs)
 
110
 
 
111
@@ -875,7 +873,6 @@ class BasicTransactionTestCase(BasicTestCase):
 
112
 
 
113
     #----------------------------------------
 
114
 
 
115
-    if db.version() >= (4, 2) :
 
116
         def test_get_tx_max(self) :
 
117
             self.assertEqual(self.env.get_tx_max(), 30)
 
118
 
 
119
diff --git a/Lib/bsddb/test/test_compat.py b/Lib/bsddb/test/test_compat.py
 
120
index 7679f19..03c8d58 100644
 
121
--- a/Lib/bsddb/test/test_compat.py
 
122
+++ b/Lib/bsddb/test/test_compat.py
 
123
@@ -11,6 +11,11 @@ from test_all import db, hashopen, btopen, rnopen, verbose, \
 
124
 
 
125
 
 
126
 class CompatibilityTestCase(unittest.TestCase):
 
127
+    import sys
 
128
+    if sys.version_info < (2, 4) :
 
129
+        def assertTrue(self, expr, msg=None):
 
130
+            self.failUnless(expr,msg=msg)
 
131
+
 
132
     def setUp(self):
 
133
         self.filename = get_new_database_path()
 
134
 
 
135
diff --git a/Lib/bsddb/test/test_db.py b/Lib/bsddb/test/test_db.py
 
136
index 8d3a32b..9448271 100644
 
137
--- a/Lib/bsddb/test/test_db.py
 
138
+++ b/Lib/bsddb/test/test_db.py
 
139
@@ -11,6 +11,8 @@ class DB(unittest.TestCase):
 
140
     if sys.version_info < (2, 4) :
 
141
         def assertTrue(self, expr, msg=None):
 
142
             self.failUnless(expr,msg=msg)
 
143
+        def assertFalse(self, expr, msg=None):
 
144
+            self.failIf(expr,msg=msg)
 
145
 
 
146
     def setUp(self):
 
147
         self.path = get_new_database_path()
 
148
@@ -19,10 +21,28 @@ class DB(unittest.TestCase):
 
149
     def tearDown(self):
 
150
         self.db.close()
 
151
         del self.db
 
152
-        test_support.rmtree(self.path)
 
153
+        test_support.unlink(self.path)
 
154
 
 
155
 class DB_general(DB) :
 
156
-    if db.version() >= (4, 2) :
 
157
+    def test_get_open_flags(self) :
 
158
+        self.db.open(self.path, dbtype=db.DB_HASH, flags = db.DB_CREATE)
 
159
+        self.assertEqual(db.DB_CREATE, self.db.get_open_flags())
 
160
+
 
161
+    def test_get_open_flags2(self) :
 
162
+        self.db.open(self.path, dbtype=db.DB_HASH, flags = db.DB_CREATE |
 
163
+                db.DB_THREAD)
 
164
+        self.assertEqual(db.DB_CREATE | db.DB_THREAD, self.db.get_open_flags())
 
165
+
 
166
+    def test_get_dbname_filename(self) :
 
167
+        self.db.open(self.path, dbtype=db.DB_HASH, flags = db.DB_CREATE)
 
168
+        self.assertEqual((self.path, None), self.db.get_dbname())
 
169
+
 
170
+    def test_get_dbname_filename_database(self) :
 
171
+        name = "jcea-random-name"
 
172
+        self.db.open(self.path, dbname=name, dbtype=db.DB_HASH,
 
173
+                flags = db.DB_CREATE)
 
174
+        self.assertEqual((self.path, name), self.db.get_dbname())
 
175
+
 
176
         def test_bt_minkey(self) :
 
177
             for i in [17, 108, 1030] :
 
178
                 self.db.set_bt_minkey(i)
 
179
@@ -44,8 +64,13 @@ class DB_general(DB) :
 
180
                 self.db.set_priority(flag)
 
181
                 self.assertEqual(flag, self.db.get_priority())
 
182
 
 
183
+    if db.version() >= (4, 3) :
 
184
+        def test_get_transactional(self) :
 
185
+            self.assertFalse(self.db.get_transactional())
 
186
+            self.db.open(self.path, dbtype=db.DB_HASH, flags = db.DB_CREATE)
 
187
+            self.assertFalse(self.db.get_transactional())
 
188
+
 
189
 class DB_hash(DB) :
 
190
-    if db.version() >= (4, 2) :
 
191
         def test_h_ffactor(self) :
 
192
             for ffactor in [4, 16, 256] :
 
193
                 self.db.set_h_ffactor(ffactor)
 
194
@@ -84,7 +109,6 @@ class DB_txn(DB) :
 
195
         del self.env
 
196
         test_support.rmtree(self.homeDir)
 
197
 
 
198
-    if db.version() >= (4, 2) :
 
199
         def test_flags(self) :
 
200
             self.db.set_flags(db.DB_CHKSUM)
 
201
             self.assertEqual(db.DB_CHKSUM, self.db.get_flags())
 
202
@@ -92,8 +116,15 @@ class DB_txn(DB) :
 
203
             self.assertEqual(db.DB_TXN_NOT_DURABLE | db.DB_CHKSUM,
 
204
                     self.db.get_flags())
 
205
 
 
206
+    if db.version() >= (4, 3) :
 
207
+        def test_get_transactional(self) :
 
208
+            self.assertFalse(self.db.get_transactional())
 
209
+            # DB_AUTO_COMMIT = Implicit transaction
 
210
+            self.db.open("XXX", dbtype=db.DB_HASH,
 
211
+                    flags = db.DB_CREATE | db.DB_AUTO_COMMIT)
 
212
+            self.assertTrue(self.db.get_transactional())
 
213
+
 
214
 class DB_recno(DB) :
 
215
-    if db.version() >= (4, 2) :
 
216
         def test_re_pad(self) :
 
217
             for i in [' ', '*'] :  # Check chars
 
218
                 self.db.set_re_pad(i)
 
219
@@ -116,7 +147,6 @@ class DB_recno(DB) :
 
220
                 self.assertEqual(i, self.db.get_re_source())
 
221
 
 
222
 class DB_queue(DB) :
 
223
-    if db.version() >= (4, 2) :
 
224
         def test_re_len(self) :
 
225
             for i in [33, 65, 300, 2000] :
 
226
                 self.db.set_re_len(i)
 
227
diff --git a/Lib/bsddb/test/test_dbenv.py b/Lib/bsddb/test/test_dbenv.py
 
228
index 37281df..1d90633 100644
 
229
--- a/Lib/bsddb/test/test_dbenv.py
 
230
+++ b/Lib/bsddb/test/test_dbenv.py
 
231
@@ -25,12 +25,31 @@ class DBEnv(unittest.TestCase):
 
232
         test_support.rmtree(self.homeDir)
 
233
 
 
234
 class DBEnv_general(DBEnv) :
 
235
+    def test_get_open_flags(self) :
 
236
+        flags = db.DB_CREATE | db.DB_INIT_MPOOL
 
237
+        self.env.open(self.homeDir, flags)
 
238
+        self.assertEqual(flags, self.env.get_open_flags())
 
239
+
 
240
+    def test_get_open_flags2(self) :
 
241
+        flags = db.DB_CREATE | db.DB_INIT_MPOOL | \
 
242
+                db.DB_INIT_LOCK | db.DB_THREAD
 
243
+        self.env.open(self.homeDir, flags)
 
244
+        self.assertEqual(flags, self.env.get_open_flags())
 
245
+
 
246
     if db.version() >= (4, 7) :
 
247
         def test_lk_partitions(self) :
 
248
             for i in [10, 20, 40] :
 
249
                 self.env.set_lk_partitions(i)
 
250
                 self.assertEqual(i, self.env.get_lk_partitions())
 
251
 
 
252
+        def test_getset_intermediate_dir_mode(self) :
 
253
+            self.assertEqual(None, self.env.get_intermediate_dir_mode())
 
254
+            for mode in ["rwx------", "rw-rw-rw-", "rw-r--r--"] :
 
255
+                self.env.set_intermediate_dir_mode(mode)
 
256
+                self.assertEqual(mode, self.env.get_intermediate_dir_mode())
 
257
+            self.assertRaises(db.DBInvalidArgError,
 
258
+                    self.env.set_intermediate_dir_mode, "abcde")
 
259
+
 
260
     if db.version() >= (4, 6) :
 
261
         def test_thread(self) :
 
262
             for i in [16, 100, 1000] :
 
263
@@ -72,7 +91,6 @@ class DBEnv_general(DBEnv) :
 
264
                     v=self.env.get_mp_max_write()
 
265
                     self.assertEqual((i, j), v)
 
266
 
 
267
-    if db.version() >= (4, 2) :
 
268
         def test_invalid_txn(self) :
 
269
             # This environment doesn't support transactions
 
270
             self.assertRaises(db.DBInvalidArgError, self.env.txn_begin)
 
271
@@ -115,7 +133,7 @@ class DBEnv_general(DBEnv) :
 
272
                 self.assertEqual(i, self.env.get_lk_max_lockers())
 
273
 
 
274
         def test_lg_regionmax(self) :
 
275
-            for i in [128, 256, 1024] :
 
276
+            for i in [128, 256, 1000] :
 
277
                 i = i*1024*1024
 
278
                 self.env.set_lg_regionmax(i)
 
279
                 j = self.env.get_lg_regionmax()
 
280
@@ -173,7 +191,11 @@ class DBEnv_general(DBEnv) :
 
281
             cachesize = (0, 2*1024*1024, 1)
 
282
             self.assertRaises(db.DBInvalidArgError,
 
283
                 self.env.set_cachesize, *cachesize)
 
284
-            self.assertEqual(cachesize2, self.env.get_cachesize())
 
285
+        cachesize3 = self.env.get_cachesize()
 
286
+        self.assertEqual(cachesize2[0], cachesize3[0])
 
287
+        self.assertEqual(cachesize2[2], cachesize3[2])
 
288
+        # In Berkeley DB 5.1, the cachesize can change when opening the Env
 
289
+        self.assertTrue(cachesize2[1] <= cachesize3[1])
 
290
 
 
291
         def test_set_cachesize_dbenv_db(self) :
 
292
             # You can not configure the cachesize using
 
293
diff --git a/Lib/bsddb/test/test_dbtables.py b/Lib/bsddb/test/test_dbtables.py
 
294
index 3ef517c..904a4de 100644
 
295
--- a/Lib/bsddb/test/test_dbtables.py
 
296
+++ b/Lib/bsddb/test/test_dbtables.py
 
297
@@ -38,6 +38,11 @@ from test_all import db, dbtables, test_support, verbose, \
 
298
 #----------------------------------------------------------------------
 
299
 
 
300
 class TableDBTestCase(unittest.TestCase):
 
301
+    import sys
 
302
+    if sys.version_info < (2, 4) :
 
303
+        def assertTrue(self, expr, msg=None):
 
304
+            self.failUnless(expr,msg=msg)
 
305
+
 
306
     db_name = 'test-table.db'
 
307
 
 
308
     def setUp(self):
 
309
diff --git a/Lib/bsddb/test/test_distributed_transactions.py b/Lib/bsddb/test/test_distributed_transactions.py
 
310
index 1711fc5..0051f20 100644
 
311
--- a/Lib/bsddb/test/test_distributed_transactions.py
 
312
+++ b/Lib/bsddb/test/test_distributed_transactions.py
 
313
@@ -19,6 +19,11 @@ from test_all import verbose
 
314
 #----------------------------------------------------------------------
 
315
 
 
316
 class DBTxn_distributed(unittest.TestCase):
 
317
+    import sys
 
318
+    if sys.version_info < (2, 4) :
 
319
+        def assertTrue(self, expr, msg=None):
 
320
+            self.failUnless(expr,msg=msg)
 
321
+
 
322
     num_txns=1234
 
323
     nosync=True
 
324
     must_open_db=False
 
325
@@ -37,15 +42,11 @@ class DBTxn_distributed(unittest.TestCase):
 
326
         self.db = db.DB(self.dbenv)
 
327
         self.db.set_re_len(db.DB_GID_SIZE)
 
328
         if must_open_db :
 
329
-            if db.version() >= (4,2) :
 
330
                 txn=self.dbenv.txn_begin()
 
331
                 self.db.open(self.filename,
 
332
                         db.DB_QUEUE, db.DB_CREATE | db.DB_THREAD, 0666,
 
333
                         txn=txn)
 
334
                 txn.commit()
 
335
-            else :
 
336
-                self.db.open(self.filename,
 
337
-                        db.DB_QUEUE, db.DB_CREATE | db.DB_THREAD, 0666)
 
338
 
 
339
     def setUp(self) :
 
340
         self.homeDir = get_new_environment_path()
 
341
diff --git a/Lib/bsddb/test/test_get_none.py b/Lib/bsddb/test/test_get_none.py
 
342
index 8763b54..ee9e1a7 100644
 
343
--- a/Lib/bsddb/test/test_get_none.py
 
344
+++ b/Lib/bsddb/test/test_get_none.py
 
345
@@ -11,6 +11,11 @@ from test_all import db, verbose, get_new_database_path
 
346
 #----------------------------------------------------------------------
 
347
 
 
348
 class GetReturnsNoneTestCase(unittest.TestCase):
 
349
+    import sys
 
350
+    if sys.version_info < (2, 4) :
 
351
+        def assertTrue(self, expr, msg=None):
 
352
+            self.failUnless(expr,msg=msg)
 
353
+
 
354
     def setUp(self):
 
355
         self.filename = get_new_database_path()
 
356
 
 
357
diff --git a/Lib/bsddb/test/test_join.py b/Lib/bsddb/test/test_join.py
 
358
index 1f0dfff..c9f6400 100644
 
359
--- a/Lib/bsddb/test/test_join.py
 
360
+++ b/Lib/bsddb/test/test_join.py
 
361
@@ -30,6 +30,11 @@ ColorIndex = [
 
362
 ]
 
363
 
 
364
 class JoinTestCase(unittest.TestCase):
 
365
+    import sys
 
366
+    if sys.version_info < (2, 4) :
 
367
+        def assertTrue(self, expr, msg=None):
 
368
+            self.failUnless(expr,msg=msg)
 
369
+
 
370
     keytype = ''
 
371
 
 
372
     def setUp(self):
 
373
diff --git a/Lib/bsddb/test/test_lock.py b/Lib/bsddb/test/test_lock.py
 
374
index 25260fc..d37f2b5 100644
 
375
--- a/Lib/bsddb/test/test_lock.py
 
376
+++ b/Lib/bsddb/test/test_lock.py
 
377
@@ -89,7 +89,6 @@ class LockingTestCase(unittest.TestCase):
 
378
         for t in threads:
 
379
             t.join()
 
380
 
 
381
-    if db.version() >= (4, 2) :
 
382
         def test03_lock_timeout(self):
 
383
             self.env.set_timeout(0, db.DB_SET_LOCK_TIMEOUT)
 
384
             self.assertEqual(self.env.get_timeout(db.DB_SET_LOCK_TIMEOUT), 0)
 
385
diff --git a/Lib/bsddb/test/test_misc.py b/Lib/bsddb/test/test_misc.py
 
386
index 8dda296..7e06b34 100644
 
387
--- a/Lib/bsddb/test/test_misc.py
 
388
+++ b/Lib/bsddb/test/test_misc.py
 
389
@@ -97,10 +97,6 @@ class MiscTestCase(unittest.TestCase):
 
390
             test_support.unlink(self.filename)
 
391
 
 
392
     def test07_DB_set_flags_persists(self):
 
393
-        if db.version() < (4,2):
 
394
-            # The get_flags API required for this to work is only available
 
395
-            # in Berkeley DB >= 4.2
 
396
-            return
 
397
         try:
 
398
             db1 = db.DB()
 
399
             db1.set_flags(db.DB_DUPSORT)
 
400
diff --git a/Lib/bsddb/test/test_queue.py b/Lib/bsddb/test/test_queue.py
 
401
index 251a8cf..c213ff4 100644
 
402
--- a/Lib/bsddb/test/test_queue.py
 
403
+++ b/Lib/bsddb/test/test_queue.py
 
404
@@ -99,11 +99,6 @@ class SimpleQueueTestCase(unittest.TestCase):
 
405
             print '\n', '-=' * 30
 
406
             print "Running %s.test02_basicPost32..." % self.__class__.__name__
 
407
 
 
408
-        if db.version() < (3, 2, 0):
 
409
-            if verbose:
 
410
-                print "Test not run, DB not new enough..."
 
411
-            return
 
412
-
 
413
         d = db.DB()
 
414
         d.set_re_len(40)  # Queues must be fixed length
 
415
         d.open(self.filename, db.DB_QUEUE, db.DB_CREATE)
 
416
diff --git a/Lib/bsddb/test/test_recno.py b/Lib/bsddb/test/test_recno.py
 
417
index 3191fdc..d3cd216 100644
 
418
--- a/Lib/bsddb/test/test_recno.py
 
419
+++ b/Lib/bsddb/test/test_recno.py
 
420
@@ -236,7 +236,9 @@ class SimpleRecnoTestCase(unittest.TestCase):
 
421
         d.close()
 
422
 
 
423
         # get the text from the backing source
 
424
-        text = open(source, 'r').read()
 
425
+        f = open(source, 'r')
 
426
+        text = f.read()
 
427
+        f.close()
 
428
         text = text.strip()
 
429
         if verbose:
 
430
             print text
 
431
@@ -256,7 +258,9 @@ class SimpleRecnoTestCase(unittest.TestCase):
 
432
         d.sync()
 
433
         d.close()
 
434
 
 
435
-        text = open(source, 'r').read()
 
436
+        f = open(source, 'r')
 
437
+        text = f.read()
 
438
+        f.close()
 
439
         text = text.strip()
 
440
         if verbose:
 
441
             print text
 
442
@@ -298,6 +302,18 @@ class SimpleRecnoTestCase(unittest.TestCase):
 
443
         c.close()
 
444
         d.close()
 
445
 
 
446
+    def test04_get_size_empty(self) :
 
447
+        d = db.DB()
 
448
+        d.open(self.filename, dbtype=db.DB_RECNO, flags=db.DB_CREATE)
 
449
+
 
450
+        row_id = d.append(' ')
 
451
+        self.assertEqual(1, d.get_size(key=row_id))
 
452
+        row_id = d.append('')
 
453
+        self.assertEqual(0, d.get_size(key=row_id))
 
454
+
 
455
+
 
456
+
 
457
+
 
458
 
 
459
 #----------------------------------------------------------------------
 
460
 
 
461
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
 
462
index 6ce86b0..ecf73ec 100644
 
463
--- a/Modules/_bsddb.c
 
464
+++ b/Modules/_bsddb.c
 
465
@@ -202,9 +202,7 @@ static PyObject* DBFileExistsError;     /* EEXIST */
 
466
 static PyObject* DBNoSuchFileError;     /* ENOENT */
 
467
 static PyObject* DBPermissionsError;    /* EPERM  */
 
468
 
 
469
-#if (DBVER >= 42)
 
470
 static PyObject* DBRepHandleDeadError;  /* DB_REP_HANDLE_DEAD */
 
471
-#endif
 
472
 #if (DBVER >= 44)
 
473
 static PyObject* DBRepLockoutError;     /* DB_REP_LOCKOUT */
 
474
 #endif
 
475
@@ -715,9 +713,7 @@ static int makeDBError(int err)
 
476
         case ENOENT:  errObj = DBNoSuchFileError;   break;
 
477
         case EPERM :  errObj = DBPermissionsError;  break;
 
478
 
 
479
-#if (DBVER >= 42)
 
480
         case DB_REP_HANDLE_DEAD : errObj = DBRepHandleDeadError; break;
 
481
-#endif
 
482
 #if (DBVER >= 44)
 
483
         case DB_REP_LOCKOUT : errObj = DBRepLockoutError; break;
 
484
 #endif
 
485
@@ -2132,7 +2128,7 @@ DB_get_size(DBObject* self, PyObject* args, PyObject* kwargs)
 
486
     MYDB_BEGIN_ALLOW_THREADS;
 
487
     err = self->db->get(self->db, txn, &key, &data, flags);
 
488
     MYDB_END_ALLOW_THREADS;
 
489
-    if (err == DB_BUFFER_SMALL) {
 
490
+    if ((err == DB_BUFFER_SMALL) || (err == 0)) {
 
491
         retval = NUMBER_FromLong((long)data.size);
 
492
         err = 0;
 
493
     }
 
494
@@ -2385,9 +2381,7 @@ DB_open(DBObject* self, PyObject* args, PyObject* kwargs)
 
495
         return NULL;
 
496
     }
 
497
 
 
498
-#if (DBVER >= 42)
 
499
     self->db->get_flags(self->db, &self->setflags);
 
500
-#endif
 
501
 
 
502
     self->flags = flags;
 
503
 
 
504
@@ -2539,6 +2533,37 @@ DB_get_priority(DBObject* self)
 
505
 #endif
 
506
 
 
507
 static PyObject*
 
508
+DB_get_dbname(DBObject* self)
 
509
+{
 
510
+    int err;
 
511
+    const char *filename, *dbname;
 
512
+
 
513
+    CHECK_DB_NOT_CLOSED(self);
 
514
+
 
515
+    MYDB_BEGIN_ALLOW_THREADS;
 
516
+    err = self->db->get_dbname(self->db, &filename, &dbname);
 
517
+    MYDB_END_ALLOW_THREADS;
 
518
+    RETURN_IF_ERR();
 
519
+    /* If "dbname==NULL", it is correctly converted to "None" */
 
520
+    return Py_BuildValue("(ss)", filename, dbname);
 
521
+}
 
522
+
 
523
+static PyObject*
 
524
+DB_get_open_flags(DBObject* self)
 
525
+{
 
526
+    int err;
 
527
+    unsigned int flags;
 
528
+
 
529
+    CHECK_DB_NOT_CLOSED(self);
 
530
+
 
531
+    MYDB_BEGIN_ALLOW_THREADS;
 
532
+    err = self->db->get_open_flags(self->db, &flags);
 
533
+    MYDB_END_ALLOW_THREADS;
 
534
+    RETURN_IF_ERR();
 
535
+    return NUMBER_FromLong(flags);
 
536
+}
 
537
+
 
538
+static PyObject*
 
539
 DB_set_q_extentsize(DBObject* self, PyObject* args)
 
540
 {
 
541
     int err;
 
542
@@ -2555,7 +2580,6 @@ DB_set_q_extentsize(DBObject* self, PyObject* args)
 
543
     RETURN_NONE();
 
544
 }
 
545
 
 
546
-#if (DBVER >= 42)
 
547
 static PyObject*
 
548
 DB_get_q_extentsize(DBObject* self)
 
549
 {
 
550
@@ -2570,7 +2594,6 @@ DB_get_q_extentsize(DBObject* self)
 
551
     RETURN_IF_ERR();
 
552
     return NUMBER_FromLong(extentsize);
 
553
 }
 
554
-#endif
 
555
 
 
556
 static PyObject*
 
557
 DB_set_bt_minkey(DBObject* self, PyObject* args)
 
558
@@ -2588,7 +2611,6 @@ DB_set_bt_minkey(DBObject* self, PyObject* args)
 
559
     RETURN_NONE();
 
560
 }
 
561
 
 
562
-#if (DBVER >= 42)
 
563
 static PyObject*
 
564
 DB_get_bt_minkey(DBObject* self)
 
565
 {
 
566
@@ -2603,7 +2625,6 @@ DB_get_bt_minkey(DBObject* self)
 
567
     RETURN_IF_ERR();
 
568
     return NUMBER_FromLong(bt_minkey);
 
569
 }
 
570
-#endif
 
571
 
 
572
 static int
 
573
 _default_cmp(const DBT *leftKey,
 
574
@@ -2759,7 +2780,6 @@ DB_set_cachesize(DBObject* self, PyObject* args)
 
575
     RETURN_NONE();
 
576
 }
 
577
 
 
578
-#if (DBVER >= 42)
 
579
 static PyObject*
 
580
 DB_get_cachesize(DBObject* self)
 
581
 {
 
582
@@ -2777,7 +2797,6 @@ DB_get_cachesize(DBObject* self)
 
583
 
 
584
     return Py_BuildValue("(iii)", gbytes, bytes, ncache);
 
585
 }
 
586
-#endif
 
587
 
 
588
 static PyObject*
 
589
 DB_set_flags(DBObject* self, PyObject* args)
 
590
@@ -2797,7 +2816,6 @@ DB_set_flags(DBObject* self, PyObject* args)
 
591
     RETURN_NONE();
 
592
 }
 
593
 
 
594
-#if (DBVER >= 42)
 
595
 static PyObject*
 
596
 DB_get_flags(DBObject* self)
 
597
 {
 
598
@@ -2812,6 +2830,35 @@ DB_get_flags(DBObject* self)
 
599
     RETURN_IF_ERR();
 
600
     return NUMBER_FromLong(flags);
 
601
 }
 
602
+
 
603
+#if (DBVER >= 43)
 
604
+static PyObject*
 
605
+DB_get_transactional(DBObject* self)
 
606
+{
 
607
+    int err;
 
608
+
 
609
+    CHECK_DB_NOT_CLOSED(self);
 
610
+
 
611
+    MYDB_BEGIN_ALLOW_THREADS;
 
612
+    err = self->db->get_transactional(self->db);
 
613
+    MYDB_END_ALLOW_THREADS;
 
614
+
 
615
+    if(err == 0) {
 
616
+        Py_INCREF(Py_False);
 
617
+        return Py_False;
 
618
+    } else if(err == 1) {
 
619
+        Py_INCREF(Py_True);
 
620
+        return Py_True;
 
621
+    }
 
622
+
 
623
+    /*
 
624
+    ** If we reach there, there was an error. The
 
625
+    ** "return" should be unreachable.
 
626
+    */
 
627
+    RETURN_IF_ERR();
 
628
+    assert(0);  /* This coude SHOULD be unreachable */
 
629
+    return NULL;
 
630
+}
 
631
 #endif
 
632
 
 
633
 static PyObject*
 
634
@@ -2830,7 +2877,6 @@ DB_set_h_ffactor(DBObject* self, PyObject* args)
 
635
     RETURN_NONE();
 
636
 }
 
637
 
 
638
-#if (DBVER >= 42)
 
639
 static PyObject*
 
640
 DB_get_h_ffactor(DBObject* self)
 
641
 {
 
642
@@ -2845,7 +2891,6 @@ DB_get_h_ffactor(DBObject* self)
 
643
     RETURN_IF_ERR();
 
644
     return NUMBER_FromLong(ffactor);
 
645
 }
 
646
-#endif
 
647
 
 
648
 static PyObject*
 
649
 DB_set_h_nelem(DBObject* self, PyObject* args)
 
650
@@ -2863,7 +2908,6 @@ DB_set_h_nelem(DBObject* self, PyObject* args)
 
651
     RETURN_NONE();
 
652
 }
 
653
 
 
654
-#if (DBVER >= 42)
 
655
 static PyObject*
 
656
 DB_get_h_nelem(DBObject* self)
 
657
 {
 
658
@@ -2878,7 +2922,6 @@ DB_get_h_nelem(DBObject* self)
 
659
     RETURN_IF_ERR();
 
660
     return NUMBER_FromLong(nelem);
 
661
 }
 
662
-#endif
 
663
 
 
664
 static PyObject*
 
665
 DB_set_lorder(DBObject* self, PyObject* args)
 
666
@@ -2896,7 +2939,6 @@ DB_set_lorder(DBObject* self, PyObject* args)
 
667
     RETURN_NONE();
 
668
 }
 
669
 
 
670
-#if (DBVER >= 42)
 
671
 static PyObject*
 
672
 DB_get_lorder(DBObject* self)
 
673
 {
 
674
@@ -2911,7 +2953,6 @@ DB_get_lorder(DBObject* self)
 
675
     RETURN_IF_ERR();
 
676
     return NUMBER_FromLong(lorder);
 
677
 }
 
678
-#endif
 
679
 
 
680
 static PyObject*
 
681
 DB_set_pagesize(DBObject* self, PyObject* args)
 
682
@@ -2929,7 +2970,6 @@ DB_set_pagesize(DBObject* self, PyObject* args)
 
683
     RETURN_NONE();
 
684
 }
 
685
 
 
686
-#if (DBVER >= 42)
 
687
 static PyObject*
 
688
 DB_get_pagesize(DBObject* self)
 
689
 {
 
690
@@ -2944,7 +2984,6 @@ DB_get_pagesize(DBObject* self)
 
691
     RETURN_IF_ERR();
 
692
     return NUMBER_FromLong(pagesize);
 
693
 }
 
694
-#endif
 
695
 
 
696
 static PyObject*
 
697
 DB_set_re_delim(DBObject* self, PyObject* args)
 
698
@@ -2967,7 +3006,6 @@ DB_set_re_delim(DBObject* self, PyObject* args)
 
699
     RETURN_NONE();
 
700
 }
 
701
 
 
702
-#if (DBVER >= 42)
 
703
 static PyObject*
 
704
 DB_get_re_delim(DBObject* self)
 
705
 {
 
706
@@ -2981,7 +3019,6 @@ DB_get_re_delim(DBObject* self)
 
707
     RETURN_IF_ERR();
 
708
     return NUMBER_FromLong(re_delim);
 
709
 }
 
710
-#endif
 
711
 
 
712
 static PyObject*
 
713
 DB_set_re_len(DBObject* self, PyObject* args)
 
714
@@ -2999,7 +3036,6 @@ DB_set_re_len(DBObject* self, PyObject* args)
 
715
     RETURN_NONE();
 
716
 }
 
717
 
 
718
-#if (DBVER >= 42)
 
719
 static PyObject*
 
720
 DB_get_re_len(DBObject* self)
 
721
 {
 
722
@@ -3014,7 +3050,6 @@ DB_get_re_len(DBObject* self)
 
723
     RETURN_IF_ERR();
 
724
     return NUMBER_FromLong(re_len);
 
725
 }
 
726
-#endif
 
727
 
 
728
 static PyObject*
 
729
 DB_set_re_pad(DBObject* self, PyObject* args)
 
730
@@ -3036,7 +3071,6 @@ DB_set_re_pad(DBObject* self, PyObject* args)
 
731
     RETURN_NONE();
 
732
 }
 
733
 
 
734
-#if (DBVER >= 42)
 
735
 static PyObject*
 
736
 DB_get_re_pad(DBObject* self)
 
737
 {
 
738
@@ -3050,7 +3084,6 @@ DB_get_re_pad(DBObject* self)
 
739
     RETURN_IF_ERR();
 
740
     return NUMBER_FromLong(re_pad);
 
741
 }
 
742
-#endif
 
743
 
 
744
 static PyObject*
 
745
 DB_set_re_source(DBObject* self, PyObject* args)
 
746
@@ -3069,7 +3102,6 @@ DB_set_re_source(DBObject* self, PyObject* args)
 
747
     RETURN_NONE();
 
748
 }
 
749
 
 
750
-#if (DBVER >= 42)
 
751
 static PyObject*
 
752
 DB_get_re_source(DBObject* self)
 
753
 {
 
754
@@ -3084,7 +3116,6 @@ DB_get_re_source(DBObject* self)
 
755
     RETURN_IF_ERR();
 
756
     return PyBytes_FromString(source);
 
757
 }
 
758
-#endif
 
759
 
 
760
 static PyObject*
 
761
 DB_stat(DBObject* self, PyObject* args, PyObject* kwargs)
 
762
@@ -3381,7 +3412,6 @@ DB_set_encrypt(DBObject* self, PyObject* args, PyObject* kwargs)
 
763
     RETURN_NONE();
 
764
 }
 
765
 
 
766
-#if (DBVER >= 42)
 
767
 static PyObject*
 
768
 DB_get_encrypt_flags(DBObject* self)
 
769
 {
 
770
@@ -3396,7 +3426,6 @@ DB_get_encrypt_flags(DBObject* self)
 
771
 
 
772
     return NUMBER_FromLong(flags);
 
773
 }
 
774
-#endif
 
775
 
 
776
 
 
777
 
 
778
@@ -4987,7 +5016,6 @@ DBEnv_set_encrypt(DBEnvObject* self, PyObject* args, PyObject* kwargs)
 
779
     RETURN_NONE();
 
780
 }
 
781
 
 
782
-#if (DBVER >= 42)
 
783
 static PyObject*
 
784
 DBEnv_get_encrypt_flags(DBEnvObject* self)
 
785
 {
 
786
@@ -5025,7 +5053,6 @@ DBEnv_get_timeout(DBEnvObject* self, PyObject* args, PyObject* kwargs)
 
787
     RETURN_IF_ERR();
 
788
     return NUMBER_FromLong(timeout);
 
789
 }
 
790
-#endif
 
791
 
 
792
 
 
793
 static PyObject*
 
794
@@ -5064,7 +5091,6 @@ DBEnv_set_shm_key(DBEnvObject* self, PyObject* args)
 
795
     RETURN_NONE();
 
796
 }
 
797
 
 
798
-#if (DBVER >= 42)
 
799
 static PyObject*
 
800
 DBEnv_get_shm_key(DBEnvObject* self)
 
801
 {
 
802
@@ -5081,7 +5107,6 @@ DBEnv_get_shm_key(DBEnvObject* self)
 
803
 
 
804
     return NUMBER_FromLong(shm_key);
 
805
 }
 
806
-#endif
 
807
 
 
808
 #if (DBVER >= 46)
 
809
 static PyObject*
 
810
@@ -5170,7 +5195,6 @@ DBEnv_set_cachesize(DBEnvObject* self, PyObject* args)
 
811
     RETURN_NONE();
 
812
 }
 
813
 
 
814
-#if (DBVER >= 42)
 
815
 static PyObject*
 
816
 DBEnv_get_cachesize(DBEnvObject* self)
 
817
 {
 
818
@@ -5188,7 +5212,6 @@ DBEnv_get_cachesize(DBEnvObject* self)
 
819
 
 
820
     return Py_BuildValue("(iii)", gbytes, bytes, ncache);
 
821
 }
 
822
-#endif
 
823
 
 
824
 
 
825
 static PyObject*
 
826
@@ -5208,7 +5231,6 @@ DBEnv_set_flags(DBEnvObject* self, PyObject* args)
 
827
     RETURN_NONE();
 
828
 }
 
829
 
 
830
-#if (DBVER >= 42)
 
831
 static PyObject*
 
832
 DBEnv_get_flags(DBEnvObject* self)
 
833
 {
 
834
@@ -5223,7 +5245,6 @@ DBEnv_get_flags(DBEnvObject* self)
 
835
     RETURN_IF_ERR();
 
836
     return NUMBER_FromLong(flags);
 
837
 }
 
838
-#endif
 
839
 
 
840
 #if (DBVER >= 47)
 
841
 static PyObject*
 
842
@@ -5423,7 +5444,6 @@ DBEnv_set_data_dir(DBEnvObject* self, PyObject* args)
 
843
     RETURN_NONE();
 
844
 }
 
845
 
 
846
-#if (DBVER >= 42)
 
847
 static PyObject*
 
848
 DBEnv_get_data_dirs(DBEnvObject* self)
 
849
 {
 
850
@@ -5463,7 +5483,6 @@ DBEnv_get_data_dirs(DBEnvObject* self)
 
851
     }
 
852
     return tuple;
 
853
 }
 
854
-#endif
 
855
 
 
856
 #if (DBVER >= 44)
 
857
 static PyObject*
 
858
@@ -5513,7 +5532,6 @@ DBEnv_set_lg_bsize(DBEnvObject* self, PyObject* args)
 
859
     RETURN_NONE();
 
860
 }
 
861
 
 
862
-#if (DBVER >= 42)
 
863
 static PyObject*
 
864
 DBEnv_get_lg_bsize(DBEnvObject* self)
 
865
 {
 
866
@@ -5528,7 +5546,6 @@ DBEnv_get_lg_bsize(DBEnvObject* self)
 
867
     RETURN_IF_ERR();
 
868
     return NUMBER_FromLong(lg_bsize);
 
869
 }
 
870
-#endif
 
871
 
 
872
 static PyObject*
 
873
 DBEnv_set_lg_dir(DBEnvObject* self, PyObject* args)
 
874
@@ -5547,7 +5564,6 @@ DBEnv_set_lg_dir(DBEnvObject* self, PyObject* args)
 
875
     RETURN_NONE();
 
876
 }
 
877
 
 
878
-#if (DBVER >= 42)
 
879
 static PyObject*
 
880
 DBEnv_get_lg_dir(DBEnvObject* self)
 
881
 {
 
882
@@ -5562,7 +5578,6 @@ DBEnv_get_lg_dir(DBEnvObject* self)
 
883
     RETURN_IF_ERR();
 
884
     return PyBytes_FromString(dirp);
 
885
 }
 
886
-#endif
 
887
 
 
888
 static PyObject*
 
889
 DBEnv_set_lg_max(DBEnvObject* self, PyObject* args)
 
890
@@ -5580,7 +5595,6 @@ DBEnv_set_lg_max(DBEnvObject* self, PyObject* args)
 
891
     RETURN_NONE();
 
892
 }
 
893
 
 
894
-#if (DBVER >= 42)
 
895
 static PyObject*
 
896
 DBEnv_get_lg_max(DBEnvObject* self)
 
897
 {
 
898
@@ -5595,8 +5609,6 @@ DBEnv_get_lg_max(DBEnvObject* self)
 
899
     RETURN_IF_ERR();
 
900
     return NUMBER_FromLong(lg_max);
 
901
 }
 
902
-#endif
 
903
-
 
904
 
 
905
 static PyObject*
 
906
 DBEnv_set_lg_regionmax(DBEnvObject* self, PyObject* args)
 
907
@@ -5614,7 +5626,6 @@ DBEnv_set_lg_regionmax(DBEnvObject* self, PyObject* args)
 
908
     RETURN_NONE();
 
909
 }
 
910
 
 
911
-#if (DBVER >= 42)
 
912
 static PyObject*
 
913
 DBEnv_get_lg_regionmax(DBEnvObject* self)
 
914
 {
 
915
@@ -5629,7 +5640,6 @@ DBEnv_get_lg_regionmax(DBEnvObject* self)
 
916
     RETURN_IF_ERR();
 
917
     return NUMBER_FromLong(lg_regionmax);
 
918
 }
 
919
-#endif
 
920
 
 
921
 #if (DBVER >= 47)
 
922
 static PyObject*
 
923
@@ -5680,7 +5690,6 @@ DBEnv_set_lk_detect(DBEnvObject* self, PyObject* args)
 
924
     RETURN_NONE();
 
925
 }
 
926
 
 
927
-#if (DBVER >= 42)
 
928
 static PyObject*
 
929
 DBEnv_get_lk_detect(DBEnvObject* self)
 
930
 {
 
931
@@ -5695,8 +5704,6 @@ DBEnv_get_lk_detect(DBEnvObject* self)
 
932
     RETURN_IF_ERR();
 
933
     return NUMBER_FromLong(lk_detect);
 
934
 }
 
935
-#endif
 
936
-
 
937
 
 
938
 #if (DBVER < 45)
 
939
 static PyObject*
 
940
@@ -5734,7 +5741,6 @@ DBEnv_set_lk_max_locks(DBEnvObject* self, PyObject* args)
 
941
     RETURN_NONE();
 
942
 }
 
943
 
 
944
-#if (DBVER >= 42)
 
945
 static PyObject*
 
946
 DBEnv_get_lk_max_locks(DBEnvObject* self)
 
947
 {
 
948
@@ -5749,7 +5755,6 @@ DBEnv_get_lk_max_locks(DBEnvObject* self)
 
949
     RETURN_IF_ERR();
 
950
     return NUMBER_FromLong(lk_max);
 
951
 }
 
952
-#endif
 
953
 
 
954
 static PyObject*
 
955
 DBEnv_set_lk_max_lockers(DBEnvObject* self, PyObject* args)
 
956
@@ -5767,7 +5772,6 @@ DBEnv_set_lk_max_lockers(DBEnvObject* self, PyObject* args)
 
957
     RETURN_NONE();
 
958
 }
 
959
 
 
960
-#if (DBVER >= 42)
 
961
 static PyObject*
 
962
 DBEnv_get_lk_max_lockers(DBEnvObject* self)
 
963
 {
 
964
@@ -5782,7 +5786,6 @@ DBEnv_get_lk_max_lockers(DBEnvObject* self)
 
965
     RETURN_IF_ERR();
 
966
     return NUMBER_FromLong(lk_max);
 
967
 }
 
968
-#endif
 
969
 
 
970
 static PyObject*
 
971
 DBEnv_set_lk_max_objects(DBEnvObject* self, PyObject* args)
 
972
@@ -5800,7 +5803,6 @@ DBEnv_set_lk_max_objects(DBEnvObject* self, PyObject* args)
 
973
     RETURN_NONE();
 
974
 }
 
975
 
 
976
-#if (DBVER >= 42)
 
977
 static PyObject*
 
978
 DBEnv_get_lk_max_objects(DBEnvObject* self)
 
979
 {
 
980
@@ -5815,9 +5817,7 @@ DBEnv_get_lk_max_objects(DBEnvObject* self)
 
981
     RETURN_IF_ERR();
 
982
     return NUMBER_FromLong(lk_max);
 
983
 }
 
984
-#endif
 
985
 
 
986
-#if (DBVER >= 42)
 
987
 static PyObject*
 
988
 DBEnv_get_mp_mmapsize(DBEnvObject* self)
 
989
 {
 
990
@@ -5832,8 +5832,6 @@ DBEnv_get_mp_mmapsize(DBEnvObject* self)
 
991
     RETURN_IF_ERR();
 
992
     return NUMBER_FromLong(mmapsize);
 
993
 }
 
994
-#endif
 
995
-
 
996
 
 
997
 static PyObject*
 
998
 DBEnv_set_mp_mmapsize(DBEnvObject* self, PyObject* args)
 
999
@@ -5869,8 +5867,6 @@ DBEnv_set_tmp_dir(DBEnvObject* self, PyObject* args)
 
1000
     RETURN_NONE();
 
1001
 }
 
1002
 
 
1003
-
 
1004
-#if (DBVER >= 42)
 
1005
 static PyObject*
 
1006
 DBEnv_get_tmp_dir(DBEnvObject* self)
 
1007
 {
 
1008
@@ -5887,8 +5883,6 @@ DBEnv_get_tmp_dir(DBEnvObject* self)
 
1009
 
 
1010
     return PyBytes_FromString(dirpp);
 
1011
 }
 
1012
-#endif
 
1013
-
 
1014
 
 
1015
 static PyObject*
 
1016
 DBEnv_txn_recover(DBEnvObject* self)
 
1017
@@ -6003,8 +5997,6 @@ DBEnv_txn_checkpoint(DBEnvObject* self, PyObject* args)
 
1018
     RETURN_NONE();
 
1019
 }
 
1020
 
 
1021
-
 
1022
-#if (DBVER >= 42)
 
1023
 static PyObject*
 
1024
 DBEnv_get_tx_max(DBEnvObject* self)
 
1025
 {
 
1026
@@ -6019,8 +6011,6 @@ DBEnv_get_tx_max(DBEnvObject* self)
 
1027
     RETURN_IF_ERR();
 
1028
     return PyLong_FromUnsignedLong(max);
 
1029
 }
 
1030
-#endif
 
1031
-
 
1032
 
 
1033
 static PyObject*
 
1034
 DBEnv_set_tx_max(DBEnvObject* self, PyObject* args)
 
1035
@@ -6038,8 +6028,6 @@ DBEnv_set_tx_max(DBEnvObject* self, PyObject* args)
 
1036
     RETURN_NONE();
 
1037
 }
 
1038
 
 
1039
-
 
1040
-#if (DBVER >= 42)
 
1041
 static PyObject*
 
1042
 DBEnv_get_tx_timestamp(DBEnvObject* self)
 
1043
 {
 
1044
@@ -6054,7 +6042,6 @@ DBEnv_get_tx_timestamp(DBEnvObject* self)
 
1045
     RETURN_IF_ERR();
 
1046
     return NUMBER_FromLong(timestamp);
 
1047
 }
 
1048
-#endif
 
1049
 
 
1050
 static PyObject*
 
1051
 DBEnv_set_tx_timestamp(DBEnvObject* self, PyObject* args)
 
1052
@@ -6756,6 +6743,55 @@ DBEnv_set_private(DBEnvObject* self, PyObject* private_obj)
 
1053
     RETURN_NONE();
 
1054
 }
 
1055
 
 
1056
+#if (DBVER >= 47)
 
1057
+static PyObject*
 
1058
+DBEnv_set_intermediate_dir_mode(DBEnvObject* self, PyObject* args)
 
1059
+{
 
1060
+    int err;
 
1061
+    const char *mode;
 
1062
+
 
1063
+    if (!PyArg_ParseTuple(args,"s:set_intermediate_dir_mode", &mode))
 
1064
+        return NULL;
 
1065
+
 
1066
+    CHECK_ENV_NOT_CLOSED(self);
 
1067
+
 
1068
+    MYDB_BEGIN_ALLOW_THREADS;
 
1069
+    err = self->db_env->set_intermediate_dir_mode(self->db_env, mode);
 
1070
+    MYDB_END_ALLOW_THREADS;
 
1071
+    RETURN_IF_ERR();
 
1072
+    RETURN_NONE();
 
1073
+}
 
1074
+
 
1075
+static PyObject*
 
1076
+DBEnv_get_intermediate_dir_mode(DBEnvObject* self)
 
1077
+{
 
1078
+    int err;
 
1079
+    const char *mode;
 
1080
+
 
1081
+    CHECK_ENV_NOT_CLOSED(self);
 
1082
+
 
1083
+    MYDB_BEGIN_ALLOW_THREADS;
 
1084
+    err = self->db_env->get_intermediate_dir_mode(self->db_env, &mode);
 
1085
+    MYDB_END_ALLOW_THREADS;
 
1086
+    RETURN_IF_ERR();
 
1087
+    return Py_BuildValue("s", mode);
 
1088
+}
 
1089
+#endif
 
1090
+
 
1091
+static PyObject*
 
1092
+DBEnv_get_open_flags(DBEnvObject* self)
 
1093
+{
 
1094
+    int err;
 
1095
+    unsigned int flags;
 
1096
+
 
1097
+    CHECK_ENV_NOT_CLOSED(self);
 
1098
+
 
1099
+    MYDB_BEGIN_ALLOW_THREADS;
 
1100
+    err = self->db_env->get_open_flags(self->db_env, &flags);
 
1101
+    MYDB_END_ALLOW_THREADS;
 
1102
+    RETURN_IF_ERR();
 
1103
+    return NUMBER_FromLong(flags);
 
1104
+}
 
1105
 
 
1106
 #if (DBVER < 48)
 
1107
 static PyObject*
 
1108
@@ -6875,7 +6911,6 @@ DBEnv_set_verbose(DBEnvObject* self, PyObject* args)
 
1109
     RETURN_NONE();
 
1110
 }
 
1111
 
 
1112
-#if (DBVER >= 42)
 
1113
 static PyObject*
 
1114
 DBEnv_get_verbose(DBEnvObject* self, PyObject* args)
 
1115
 {
 
1116
@@ -6893,7 +6928,6 @@ DBEnv_get_verbose(DBEnvObject* self, PyObject* args)
 
1117
     RETURN_IF_ERR();
 
1118
     return PyBool_FromLong(verbose);
 
1119
 }
 
1120
-#endif
 
1121
 
 
1122
 #if (DBVER >= 45)
 
1123
 static void
 
1124
@@ -6975,9 +7009,7 @@ DBEnv_rep_process_message(DBEnvObject* self, PyObject* args)
 
1125
     PyObject *control_py, *rec_py;
 
1126
     DBT control, rec;
 
1127
     int envid;
 
1128
-#if (DBVER >= 42)
 
1129
     DB_LSN lsn;
 
1130
-#endif
 
1131
 
 
1132
     if (!PyArg_ParseTuple(args, "OOi:rep_process_message", &control_py,
 
1133
                 &rec_py, &envid))
 
1134
@@ -6994,13 +7026,8 @@ DBEnv_rep_process_message(DBEnvObject* self, PyObject* args)
 
1135
     err = self->db_env->rep_process_message(self->db_env, &control, &rec,
 
1136
             envid, &lsn);
 
1137
 #else
 
1138
-#if (DBVER >= 42)
 
1139
     err = self->db_env->rep_process_message(self->db_env, &control, &rec,
 
1140
             &envid, &lsn);
 
1141
-#else
 
1142
-    err = self->db_env->rep_process_message(self->db_env, &control, &rec,
 
1143
-            &envid);
 
1144
-#endif
 
1145
 #endif
 
1146
     MYDB_END_ALLOW_THREADS;
 
1147
     switch (err) {
 
1148
@@ -7029,12 +7056,10 @@ DBEnv_rep_process_message(DBEnvObject* self, PyObject* args)
 
1149
                 return r;
 
1150
                 break;
 
1151
             }
 
1152
-#if (DBVER >= 42)
 
1153
         case DB_REP_NOTPERM :
 
1154
         case DB_REP_ISPERM :
 
1155
             return Py_BuildValue("(i(ll))", err, lsn.file, lsn.offset);
 
1156
             break;
 
1157
-#endif
 
1158
     }
 
1159
     RETURN_IF_ERR();
 
1160
     return Py_BuildValue("(OO)", Py_None, Py_None);
 
1161
@@ -7086,20 +7111,6 @@ _DBEnv_rep_transportCallback(DB_ENV* db_env, const DBT* control, const DBT* rec,
 
1162
     return ret;
 
1163
 }
 
1164
 
 
1165
-#if (DBVER <= 41)
 
1166
-static int
 
1167
-_DBEnv_rep_transportCallbackOLD(DB_ENV* db_env, const DBT* control, const DBT* rec,
 
1168
-        int envid, u_int32_t flags)
 
1169
-{
 
1170
-    DB_LSN lsn;
 
1171
-
 
1172
-    lsn.file = -1;  /* Dummy values */
 
1173
-    lsn.offset = -1;
 
1174
-    return _DBEnv_rep_transportCallback(db_env, control, rec, &lsn, envid,
 
1175
-            flags);
 
1176
-}
 
1177
-#endif
 
1178
-
 
1179
 static PyObject*
 
1180
 DBEnv_rep_set_transport(DBEnvObject* self, PyObject* args)
 
1181
 {
 
1182
@@ -7120,13 +7131,8 @@ DBEnv_rep_set_transport(DBEnvObject* self, PyObject* args)
 
1183
     err = self->db_env->rep_set_transport(self->db_env, envid,
 
1184
             &_DBEnv_rep_transportCallback);
 
1185
 #else
 
1186
-#if (DBVER >= 42)
 
1187
     err = self->db_env->set_rep_transport(self->db_env, envid,
 
1188
             &_DBEnv_rep_transportCallback);
 
1189
-#else
 
1190
-    err = self->db_env->set_rep_transport(self->db_env, envid,
 
1191
-            &_DBEnv_rep_transportCallbackOLD);
 
1192
-#endif
 
1193
 #endif
 
1194
     MYDB_END_ALLOW_THREADS;
 
1195
     RETURN_IF_ERR();
 
1196
@@ -8482,65 +8488,43 @@ static PyMethodDef DB_methods[] = {
 
1197
     {"remove",          (PyCFunction)DB_remove,         METH_VARARGS|METH_KEYWORDS},
 
1198
     {"rename",          (PyCFunction)DB_rename,         METH_VARARGS},
 
1199
     {"set_bt_minkey",   (PyCFunction)DB_set_bt_minkey,  METH_VARARGS},
 
1200
-#if (DBVER >= 42)
 
1201
     {"get_bt_minkey",   (PyCFunction)DB_get_bt_minkey,  METH_NOARGS},
 
1202
-#endif
 
1203
     {"set_bt_compare",  (PyCFunction)DB_set_bt_compare, METH_O},
 
1204
     {"set_cachesize",   (PyCFunction)DB_set_cachesize,  METH_VARARGS},
 
1205
-#if (DBVER >= 42)
 
1206
     {"get_cachesize",   (PyCFunction)DB_get_cachesize,  METH_NOARGS},
 
1207
-#endif
 
1208
     {"set_encrypt",     (PyCFunction)DB_set_encrypt,    METH_VARARGS|METH_KEYWORDS},
 
1209
-#if (DBVER >= 42)
 
1210
     {"get_encrypt_flags", (PyCFunction)DB_get_encrypt_flags, METH_NOARGS},
 
1211
-#endif
 
1212
-
 
1213
     {"set_flags",       (PyCFunction)DB_set_flags,      METH_VARARGS},
 
1214
-#if (DBVER >= 42)
 
1215
     {"get_flags",       (PyCFunction)DB_get_flags,      METH_NOARGS},
 
1216
+#if (DBVER >= 43)
 
1217
+    {"get_transactional", (PyCFunction)DB_get_transactional, METH_NOARGS},
 
1218
 #endif
 
1219
     {"set_h_ffactor",   (PyCFunction)DB_set_h_ffactor,  METH_VARARGS},
 
1220
-#if (DBVER >= 42)
 
1221
     {"get_h_ffactor",   (PyCFunction)DB_get_h_ffactor,  METH_NOARGS},
 
1222
-#endif
 
1223
     {"set_h_nelem",     (PyCFunction)DB_set_h_nelem,    METH_VARARGS},
 
1224
-#if (DBVER >= 42)
 
1225
     {"get_h_nelem",     (PyCFunction)DB_get_h_nelem,    METH_NOARGS},
 
1226
-#endif
 
1227
     {"set_lorder",      (PyCFunction)DB_set_lorder,     METH_VARARGS},
 
1228
-#if (DBVER >= 42)
 
1229
     {"get_lorder",      (PyCFunction)DB_get_lorder,     METH_NOARGS},
 
1230
-#endif
 
1231
     {"set_pagesize",    (PyCFunction)DB_set_pagesize,   METH_VARARGS},
 
1232
-#if (DBVER >= 42)
 
1233
     {"get_pagesize",    (PyCFunction)DB_get_pagesize,   METH_NOARGS},
 
1234
-#endif
 
1235
     {"set_re_delim",    (PyCFunction)DB_set_re_delim,   METH_VARARGS},
 
1236
-#if (DBVER >= 42)
 
1237
     {"get_re_delim",    (PyCFunction)DB_get_re_delim,   METH_NOARGS},
 
1238
-#endif
 
1239
     {"set_re_len",      (PyCFunction)DB_set_re_len,     METH_VARARGS},
 
1240
-#if (DBVER >= 42)
 
1241
     {"get_re_len",      (PyCFunction)DB_get_re_len,     METH_NOARGS},
 
1242
-#endif
 
1243
     {"set_re_pad",      (PyCFunction)DB_set_re_pad,     METH_VARARGS},
 
1244
-#if (DBVER >= 42)
 
1245
     {"get_re_pad",      (PyCFunction)DB_get_re_pad,     METH_NOARGS},
 
1246
-#endif
 
1247
     {"set_re_source",   (PyCFunction)DB_set_re_source,  METH_VARARGS},
 
1248
-#if (DBVER >= 42)
 
1249
     {"get_re_source",   (PyCFunction)DB_get_re_source,  METH_NOARGS},
 
1250
-#endif
 
1251
     {"set_q_extentsize",(PyCFunction)DB_set_q_extentsize, METH_VARARGS},
 
1252
-#if (DBVER >= 42)
 
1253
     {"get_q_extentsize",(PyCFunction)DB_get_q_extentsize, METH_NOARGS},
 
1254
-#endif
 
1255
     {"set_private",     (PyCFunction)DB_set_private,    METH_O},
 
1256
     {"get_private",     (PyCFunction)DB_get_private,    METH_NOARGS},
 
1257
 #if (DBVER >= 46)
 
1258
     {"set_priority",    (PyCFunction)DB_set_priority,   METH_VARARGS},
 
1259
     {"get_priority",    (PyCFunction)DB_get_priority,   METH_NOARGS},
 
1260
 #endif
 
1261
+    {"get_dbname",      (PyCFunction)DB_get_dbname,     METH_NOARGS},
 
1262
+    {"get_open_flags",  (PyCFunction)DB_get_open_flags, METH_NOARGS},
 
1263
     {"stat",            (PyCFunction)DB_stat,           METH_VARARGS|METH_KEYWORDS},
 
1264
 #if (DBVER >= 43)
 
1265
     {"stat_print",      (PyCFunction)DB_stat_print,
 
1266
@@ -8639,24 +8623,18 @@ static PyMethodDef DBEnv_methods[] = {
 
1267
     {"get_thread_count", (PyCFunction)DBEnv_get_thread_count, METH_NOARGS},
 
1268
 #endif
 
1269
     {"set_encrypt",     (PyCFunction)DBEnv_set_encrypt,      METH_VARARGS|METH_KEYWORDS},
 
1270
-#if (DBVER >= 42)
 
1271
     {"get_encrypt_flags", (PyCFunction)DBEnv_get_encrypt_flags, METH_NOARGS},
 
1272
     {"get_timeout",     (PyCFunction)DBEnv_get_timeout,
 
1273
         METH_VARARGS|METH_KEYWORDS},
 
1274
-#endif
 
1275
     {"set_timeout",     (PyCFunction)DBEnv_set_timeout,     METH_VARARGS|METH_KEYWORDS},
 
1276
     {"set_shm_key",     (PyCFunction)DBEnv_set_shm_key,     METH_VARARGS},
 
1277
-#if (DBVER >= 42)
 
1278
     {"get_shm_key",     (PyCFunction)DBEnv_get_shm_key,     METH_NOARGS},
 
1279
-#endif
 
1280
 #if (DBVER >= 46)
 
1281
     {"set_cache_max",   (PyCFunction)DBEnv_set_cache_max,   METH_VARARGS},
 
1282
     {"get_cache_max",   (PyCFunction)DBEnv_get_cache_max,   METH_NOARGS},
 
1283
 #endif
 
1284
     {"set_cachesize",   (PyCFunction)DBEnv_set_cachesize,   METH_VARARGS},
 
1285
-#if (DBVER >= 42)
 
1286
     {"get_cachesize",   (PyCFunction)DBEnv_get_cachesize,   METH_NOARGS},
 
1287
-#endif
 
1288
     {"memp_trickle",    (PyCFunction)DBEnv_memp_trickle,    METH_VARARGS},
 
1289
     {"memp_sync",       (PyCFunction)DBEnv_memp_sync,       METH_VARARGS},
 
1290
     {"memp_stat",       (PyCFunction)DBEnv_memp_stat,
 
1291
@@ -8685,33 +8663,21 @@ static PyMethodDef DBEnv_methods[] = {
 
1292
 #endif
 
1293
 #endif
 
1294
     {"set_data_dir",    (PyCFunction)DBEnv_set_data_dir,    METH_VARARGS},
 
1295
-#if (DBVER >= 42)
 
1296
     {"get_data_dirs",   (PyCFunction)DBEnv_get_data_dirs,   METH_NOARGS},
 
1297
-#endif
 
1298
-#if (DBVER >= 42)
 
1299
     {"get_flags",       (PyCFunction)DBEnv_get_flags,       METH_NOARGS},
 
1300
-#endif
 
1301
     {"set_flags",       (PyCFunction)DBEnv_set_flags,       METH_VARARGS},
 
1302
 #if (DBVER >= 47)
 
1303
     {"log_set_config",  (PyCFunction)DBEnv_log_set_config,  METH_VARARGS},
 
1304
     {"log_get_config",  (PyCFunction)DBEnv_log_get_config,  METH_VARARGS},
 
1305
 #endif
 
1306
     {"set_lg_bsize",    (PyCFunction)DBEnv_set_lg_bsize,    METH_VARARGS},
 
1307
-#if (DBVER >= 42)
 
1308
     {"get_lg_bsize",    (PyCFunction)DBEnv_get_lg_bsize,    METH_NOARGS},
 
1309
-#endif
 
1310
     {"set_lg_dir",      (PyCFunction)DBEnv_set_lg_dir,      METH_VARARGS},
 
1311
-#if (DBVER >= 42)
 
1312
     {"get_lg_dir",      (PyCFunction)DBEnv_get_lg_dir,      METH_NOARGS},
 
1313
-#endif
 
1314
     {"set_lg_max",      (PyCFunction)DBEnv_set_lg_max,      METH_VARARGS},
 
1315
-#if (DBVER >= 42)
 
1316
     {"get_lg_max",      (PyCFunction)DBEnv_get_lg_max,      METH_NOARGS},
 
1317
-#endif
 
1318
     {"set_lg_regionmax",(PyCFunction)DBEnv_set_lg_regionmax, METH_VARARGS},
 
1319
-#if (DBVER >= 42)
 
1320
     {"get_lg_regionmax",(PyCFunction)DBEnv_get_lg_regionmax, METH_NOARGS},
 
1321
-#endif
 
1322
 #if (DBVER >= 44)
 
1323
     {"set_lg_filemode", (PyCFunction)DBEnv_set_lg_filemode, METH_VARARGS},
 
1324
     {"get_lg_filemode", (PyCFunction)DBEnv_get_lg_filemode, METH_NOARGS},
 
1325
@@ -8721,36 +8687,24 @@ static PyMethodDef DBEnv_methods[] = {
 
1326
     {"get_lk_partitions", (PyCFunction)DBEnv_get_lk_partitions, METH_NOARGS},
 
1327
 #endif
 
1328
     {"set_lk_detect",   (PyCFunction)DBEnv_set_lk_detect,   METH_VARARGS},
 
1329
-#if (DBVER >= 42)
 
1330
     {"get_lk_detect",   (PyCFunction)DBEnv_get_lk_detect,   METH_NOARGS},
 
1331
-#endif
 
1332
 #if (DBVER < 45)
 
1333
     {"set_lk_max",      (PyCFunction)DBEnv_set_lk_max,      METH_VARARGS},
 
1334
 #endif
 
1335
     {"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS},
 
1336
-#if (DBVER >= 42)
 
1337
     {"get_lk_max_locks", (PyCFunction)DBEnv_get_lk_max_locks, METH_NOARGS},
 
1338
-#endif
 
1339
     {"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS},
 
1340
-#if (DBVER >= 42)
 
1341
     {"get_lk_max_lockers", (PyCFunction)DBEnv_get_lk_max_lockers, METH_NOARGS},
 
1342
-#endif
 
1343
     {"set_lk_max_objects", (PyCFunction)DBEnv_set_lk_max_objects, METH_VARARGS},
 
1344
-#if (DBVER >= 42)
 
1345
     {"get_lk_max_objects", (PyCFunction)DBEnv_get_lk_max_objects, METH_NOARGS},
 
1346
-#endif
 
1347
 #if (DBVER >= 43)
 
1348
     {"stat_print",          (PyCFunction)DBEnv_stat_print,
 
1349
         METH_VARARGS|METH_KEYWORDS},
 
1350
 #endif
 
1351
     {"set_mp_mmapsize", (PyCFunction)DBEnv_set_mp_mmapsize, METH_VARARGS},
 
1352
-#if (DBVER >= 42)
 
1353
     {"get_mp_mmapsize", (PyCFunction)DBEnv_get_mp_mmapsize, METH_NOARGS},
 
1354
-#endif
 
1355
     {"set_tmp_dir",     (PyCFunction)DBEnv_set_tmp_dir,     METH_VARARGS},
 
1356
-#if (DBVER >= 42)
 
1357
     {"get_tmp_dir",     (PyCFunction)DBEnv_get_tmp_dir,     METH_NOARGS},
 
1358
-#endif
 
1359
     {"txn_begin",       (PyCFunction)DBEnv_txn_begin,       METH_VARARGS|METH_KEYWORDS},
 
1360
     {"txn_checkpoint",  (PyCFunction)DBEnv_txn_checkpoint,  METH_VARARGS},
 
1361
     {"txn_stat",        (PyCFunction)DBEnv_txn_stat,        METH_VARARGS},
 
1362
@@ -8758,10 +8712,8 @@ static PyMethodDef DBEnv_methods[] = {
 
1363
     {"txn_stat_print",  (PyCFunction)DBEnv_txn_stat_print,
 
1364
         METH_VARARGS|METH_KEYWORDS},
 
1365
 #endif
 
1366
-#if (DBVER >= 42)
 
1367
     {"get_tx_max",      (PyCFunction)DBEnv_get_tx_max,      METH_NOARGS},
 
1368
     {"get_tx_timestamp", (PyCFunction)DBEnv_get_tx_timestamp, METH_NOARGS},
 
1369
-#endif
 
1370
     {"set_tx_max",      (PyCFunction)DBEnv_set_tx_max,      METH_VARARGS},
 
1371
     {"set_tx_timestamp", (PyCFunction)DBEnv_set_tx_timestamp, METH_VARARGS},
 
1372
     {"lock_detect",     (PyCFunction)DBEnv_lock_detect,     METH_VARARGS},
 
1373
@@ -8804,11 +8756,16 @@ static PyMethodDef DBEnv_methods[] = {
 
1374
     {"get_mp_max_write", (PyCFunction)DBEnv_get_mp_max_write, METH_NOARGS},
 
1375
 #endif
 
1376
     {"set_verbose",     (PyCFunction)DBEnv_set_verbose,     METH_VARARGS},
 
1377
-#if (DBVER >= 42)
 
1378
-    {"get_verbose",     (PyCFunction)DBEnv_get_verbose,       METH_VARARGS},
 
1379
+    {"get_verbose",     (PyCFunction)DBEnv_get_verbose,     METH_VARARGS},
 
1380
+    {"set_private",     (PyCFunction)DBEnv_set_private,     METH_O},
 
1381
+    {"get_private",     (PyCFunction)DBEnv_get_private,     METH_NOARGS},
 
1382
+    {"get_open_flags",  (PyCFunction)DBEnv_get_open_flags,  METH_NOARGS},
 
1383
+#if (DBVER >= 47)
 
1384
+    {"set_intermediate_dir_mode", (PyCFunction)DBEnv_set_intermediate_dir_mode,
 
1385
+        METH_VARARGS},
 
1386
+    {"get_intermediate_dir_mode", (PyCFunction)DBEnv_get_intermediate_dir_mode,
 
1387
+        METH_NOARGS},
 
1388
 #endif
 
1389
-    {"set_private",     (PyCFunction)DBEnv_set_private,       METH_O},
 
1390
-    {"get_private",     (PyCFunction)DBEnv_get_private,       METH_NOARGS},
 
1391
     {"rep_start",       (PyCFunction)DBEnv_rep_start,
 
1392
         METH_VARARGS|METH_KEYWORDS},
 
1393
     {"rep_set_transport", (PyCFunction)DBEnv_rep_set_transport, METH_VARARGS},
 
1394
@@ -8922,13 +8879,9 @@ DBEnv_db_home_get(DBEnvObject* self)
 
1395
 
 
1396
     CHECK_ENV_NOT_CLOSED(self);
 
1397
 
 
1398
-#if (DBVER >= 42)
 
1399
     MYDB_BEGIN_ALLOW_THREADS;
 
1400
     self->db_env->get_home(self->db_env, &home);
 
1401
     MYDB_END_ALLOW_THREADS;
 
1402
-#else
 
1403
-    home=self->db_env->db_home;
 
1404
-#endif
 
1405
 
 
1406
     if (home == NULL) {
 
1407
         RETURN_NONE();
 
1408
@@ -9298,10 +9251,25 @@ bsddb_version(PyObject* self)
 
1409
 {
 
1410
     int major, minor, patch;
 
1411
 
 
1412
+    /* This should be instantaneous, no need to release the GIL */
 
1413
     db_version(&major, &minor, &patch);
 
1414
     return Py_BuildValue("(iii)", major, minor, patch);
 
1415
 }
 
1416
 
 
1417
+#if (DBVER >= 50)
 
1418
+static PyObject*
 
1419
+bsddb_version_full(PyObject* self)
 
1420
+{
 
1421
+    char *version_string;
 
1422
+    int family, release, major, minor, patch;
 
1423
+
 
1424
+    /* This should be instantaneous, no need to release the GIL */
 
1425
+    version_string = db_full_version(&family, &release, &major, &minor, &patch);
 
1426
+    return Py_BuildValue("(siiiii)",
 
1427
+            version_string, family, release, major, minor, patch);
 
1428
+}
 
1429
+#endif
 
1430
+
 
1431
 
 
1432
 /* List of functions defined in the module */
 
1433
 static PyMethodDef bsddb_methods[] = {
 
1434
@@ -9311,6 +9279,9 @@ static PyMethodDef bsddb_methods[] = {
 
1435
     {"DBSequence",  (PyCFunction)DBSequence_construct,  METH_VARARGS | METH_KEYWORDS },
 
1436
 #endif
 
1437
     {"version",     (PyCFunction)bsddb_version,         METH_NOARGS, bsddb_version_doc},
 
1438
+#if (DBVER >= 50)
 
1439
+    {"full_version", (PyCFunction)bsddb_version_full, METH_NOARGS},
 
1440
+#endif
 
1441
     {NULL,      NULL}       /* sentinel */
 
1442
 };
 
1443
 
 
1444
@@ -9328,6 +9299,11 @@ static BSDDB_api bsddb_api;
 
1445
  */
 
1446
 #define ADD_INT(dict, NAME)         _addIntToDict(dict, #NAME, NAME)
 
1447
 
 
1448
+/*
 
1449
+** We can rename the module at import time, so the string allocated
 
1450
+** must be big enough, and any use of the name must use this particular
 
1451
+** string.
 
1452
+*/
 
1453
 #define MODULE_NAME_MAX_LEN     11
 
1454
 static char _bsddbModuleName[MODULE_NAME_MAX_LEN+1] = "_bsddb";
 
1455
 
 
1456
@@ -9428,13 +9404,7 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1457
     ADD_INT(d, DB_MAX_RECORDS);
 
1458
 
 
1459
 #if (DBVER < 48)
 
1460
-#if (DBVER >= 42)
 
1461
     ADD_INT(d, DB_RPCCLIENT);
 
1462
-#else
 
1463
-    ADD_INT(d, DB_CLIENT);
 
1464
-    /* allow apps to be written using DB_RPCCLIENT on older Berkeley DB */
 
1465
-    _addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT);
 
1466
-#endif
 
1467
 #endif
 
1468
 
 
1469
 #if (DBVER < 48)
 
1470
@@ -9477,6 +9447,14 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1471
     ADD_INT(d, DB_TXN_SYNC);
 
1472
     ADD_INT(d, DB_TXN_NOWAIT);
 
1473
 
 
1474
+#if (DBVER >= 51)
 
1475
+    ADD_INT(d, DB_TXN_BULK);
 
1476
+#endif
 
1477
+
 
1478
+#if (DBVER >= 48)
 
1479
+    ADD_INT(d, DB_CURSOR_BULK);
 
1480
+#endif
 
1481
+
 
1482
 #if (DBVER >= 46)
 
1483
     ADD_INT(d, DB_TXN_WAIT);
 
1484
 #endif
 
1485
@@ -9561,9 +9539,7 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1486
     ADD_INT(d, DB_ARCH_ABS);
 
1487
     ADD_INT(d, DB_ARCH_DATA);
 
1488
     ADD_INT(d, DB_ARCH_LOG);
 
1489
-#if (DBVER >= 42)
 
1490
     ADD_INT(d, DB_ARCH_REMOVE);
 
1491
-#endif
 
1492
 
 
1493
     ADD_INT(d, DB_BTREE);
 
1494
     ADD_INT(d, DB_HASH);
 
1495
@@ -9591,9 +9567,6 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1496
     ADD_INT(d, DB_CACHED_COUNTS);
 
1497
 #endif
 
1498
 
 
1499
-#if (DBVER <= 41)
 
1500
-    ADD_INT(d, DB_COMMIT);
 
1501
-#endif
 
1502
     ADD_INT(d, DB_CONSUME);
 
1503
     ADD_INT(d, DB_CONSUME_WAIT);
 
1504
     ADD_INT(d, DB_CURRENT);
 
1505
@@ -9671,6 +9644,10 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1506
 #if (DBVER >= 43)
 
1507
     ADD_INT(d, DB_STAT_SUBSYSTEM);
 
1508
     ADD_INT(d, DB_STAT_MEMP_HASH);
 
1509
+    ADD_INT(d, DB_STAT_LOCK_CONF);
 
1510
+    ADD_INT(d, DB_STAT_LOCK_LOCKERS);
 
1511
+    ADD_INT(d, DB_STAT_LOCK_OBJECTS);
 
1512
+    ADD_INT(d, DB_STAT_LOCK_PARAMS);
 
1513
 #endif
 
1514
 
 
1515
 #if (DBVER >= 48)
 
1516
@@ -9690,7 +9667,6 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1517
     ADD_INT(d, DB_EID_INVALID);
 
1518
     ADD_INT(d, DB_EID_BROADCAST);
 
1519
 
 
1520
-#if (DBVER >= 42)
 
1521
     ADD_INT(d, DB_TIME_NOTGRANTED);
 
1522
     ADD_INT(d, DB_TXN_NOT_DURABLE);
 
1523
     ADD_INT(d, DB_TXN_WRITE_NOSYNC);
 
1524
@@ -9698,9 +9674,8 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1525
     ADD_INT(d, DB_INIT_REP);
 
1526
     ADD_INT(d, DB_ENCRYPT);
 
1527
     ADD_INT(d, DB_CHKSUM);
 
1528
-#endif
 
1529
 
 
1530
-#if (DBVER >= 42) && (DBVER < 47)
 
1531
+#if (DBVER < 47)
 
1532
     ADD_INT(d, DB_LOG_AUTOREMOVE);
 
1533
     ADD_INT(d, DB_DIRECT_LOG);
 
1534
 #endif
 
1535
@@ -9733,6 +9708,20 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1536
     ADD_INT(d, DB_VERB_REPLICATION);
 
1537
     ADD_INT(d, DB_VERB_WAITSFOR);
 
1538
 
 
1539
+#if (DBVER >= 50)
 
1540
+    ADD_INT(d, DB_VERB_REP_SYSTEM);
 
1541
+#endif
 
1542
+
 
1543
+#if (DBVER >= 47)
 
1544
+    ADD_INT(d, DB_VERB_REP_ELECT);
 
1545
+    ADD_INT(d, DB_VERB_REP_LEASE);
 
1546
+    ADD_INT(d, DB_VERB_REP_MISC);
 
1547
+    ADD_INT(d, DB_VERB_REP_MSGS);
 
1548
+    ADD_INT(d, DB_VERB_REP_SYNC);
 
1549
+    ADD_INT(d, DB_VERB_REPMGR_CONNFAIL);
 
1550
+    ADD_INT(d, DB_VERB_REPMGR_MISC);
 
1551
+#endif
 
1552
+
 
1553
 #if (DBVER >= 45)
 
1554
     ADD_INT(d, DB_EVENT_PANIC);
 
1555
     ADD_INT(d, DB_EVENT_REP_CLIENT);
 
1556
@@ -9748,16 +9737,25 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1557
     ADD_INT(d, DB_EVENT_WRITE_FAILED);
 
1558
 #endif
 
1559
 
 
1560
+#if (DBVER >= 50)
 
1561
+    ADD_INT(d, DB_REPMGR_CONF_ELECTIONS);
 
1562
+    ADD_INT(d, DB_EVENT_REP_MASTER_FAILURE);
 
1563
+    ADD_INT(d, DB_EVENT_REP_DUPMASTER);
 
1564
+    ADD_INT(d, DB_EVENT_REP_ELECTION_FAILED);
 
1565
+#endif
 
1566
+#if (DBVER >= 48)
 
1567
+    ADD_INT(d, DB_EVENT_REG_ALIVE);
 
1568
+    ADD_INT(d, DB_EVENT_REG_PANIC);
 
1569
+#endif
 
1570
+
 
1571
     ADD_INT(d, DB_REP_DUPMASTER);
 
1572
     ADD_INT(d, DB_REP_HOLDELECTION);
 
1573
 #if (DBVER >= 44)
 
1574
     ADD_INT(d, DB_REP_IGNORE);
 
1575
     ADD_INT(d, DB_REP_JOIN_FAILURE);
 
1576
 #endif
 
1577
-#if (DBVER >= 42)
 
1578
     ADD_INT(d, DB_REP_ISPERM);
 
1579
     ADD_INT(d, DB_REP_NOTPERM);
 
1580
-#endif
 
1581
     ADD_INT(d, DB_REP_NEWSITE);
 
1582
 
 
1583
     ADD_INT(d, DB_REP_MASTER);
 
1584
@@ -9766,7 +9764,13 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1585
     ADD_INT(d, DB_REP_PERMANENT);
 
1586
 
 
1587
 #if (DBVER >= 44)
 
1588
+#if (DBVER >= 50)
 
1589
+    ADD_INT(d, DB_REP_CONF_AUTOINIT);
 
1590
+#else
 
1591
     ADD_INT(d, DB_REP_CONF_NOAUTOINIT);
 
1592
+#endif /* 5.0 */
 
1593
+#endif /* 4.4 */
 
1594
+#if (DBVER >= 44)
 
1595
     ADD_INT(d, DB_REP_CONF_DELAYCLIENT);
 
1596
     ADD_INT(d, DB_REP_CONF_BULK);
 
1597
     ADD_INT(d, DB_REP_CONF_NOWAIT);
 
1598
@@ -9774,9 +9778,7 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1599
     ADD_INT(d, DB_REP_REREQUEST);
 
1600
 #endif
 
1601
 
 
1602
-#if (DBVER >= 42)
 
1603
     ADD_INT(d, DB_REP_NOBUFFER);
 
1604
-#endif
 
1605
 
 
1606
 #if (DBVER >= 46)
 
1607
     ADD_INT(d, DB_REP_LEASE_EXPIRED);
 
1608
@@ -9819,6 +9821,28 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1609
     ADD_INT(d, DB_STAT_ALL);
 
1610
 #endif
 
1611
 
 
1612
+#if (DBVER >= 51)
 
1613
+    ADD_INT(d, DB_REPMGR_ACKS_ALL_AVAILABLE);
 
1614
+#endif
 
1615
+
 
1616
+#if (DBVER >= 48)
 
1617
+    ADD_INT(d, DB_REP_CONF_INMEM);
 
1618
+#endif
 
1619
+
 
1620
+    ADD_INT(d, DB_TIMEOUT);
 
1621
+
 
1622
+#if (DBVER >= 50)
 
1623
+    ADD_INT(d, DB_FORCESYNC);
 
1624
+#endif
 
1625
+
 
1626
+#if (DBVER >= 48)
 
1627
+    ADD_INT(d, DB_FAILCHK);
 
1628
+#endif
 
1629
+
 
1630
+#if (DBVER >= 51)
 
1631
+    ADD_INT(d, DB_HOTBACKUP_IN_PROGRESS);
 
1632
+#endif
 
1633
+
 
1634
 #if (DBVER >= 43)
 
1635
     ADD_INT(d, DB_BUFFER_SMALL);
 
1636
     ADD_INT(d, DB_SEQ_DEC);
 
1637
@@ -9856,6 +9880,10 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1638
     ADD_INT(d, DB_SET_LOCK_TIMEOUT);
 
1639
     ADD_INT(d, DB_SET_TXN_TIMEOUT);
 
1640
 
 
1641
+#if (DBVER >= 48)
 
1642
+    ADD_INT(d, DB_SET_REG_TIMEOUT);
 
1643
+#endif
 
1644
+
 
1645
     /* The exception name must be correct for pickled exception *
 
1646
      * objects to unpickle properly.                            */
 
1647
 #ifdef PYBSDDB_STANDALONE  /* different value needed for standalone pybsddb */
 
1648
@@ -9927,9 +9955,7 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1649
     MAKE_EX(DBNoSuchFileError);
 
1650
     MAKE_EX(DBPermissionsError);
 
1651
 
 
1652
-#if (DBVER >= 42)
 
1653
     MAKE_EX(DBRepHandleDeadError);
 
1654
-#endif
 
1655
 #if (DBVER >= 44)
 
1656
     MAKE_EX(DBRepLockoutError);
 
1657
 #endif
 
1658
@@ -9947,6 +9973,7 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1659
 #undef MAKE_EX
 
1660
 
 
1661
     /* Initialise the C API structure and add it to the module */
 
1662
+    bsddb_api.api_version      = PYBSDDB_API_VERSION;
 
1663
     bsddb_api.db_type          = &DB_Type;
 
1664
     bsddb_api.dbcursor_type    = &DBCursor_Type;
 
1665
     bsddb_api.dblogcursor_type = &DBLogCursor_Type;
 
1666
@@ -9955,19 +9982,25 @@ PyMODINIT_FUNC  PyInit__bsddb(void)    /* Note the two underscores */
 
1667
     bsddb_api.dblock_type      = &DBLock_Type;
 
1668
 #if (DBVER >= 43)
 
1669
     bsddb_api.dbsequence_type  = &DBSequence_Type;
 
1670
+#else
 
1671
+    bsddb_api.dbsequence_type  = NULL;
 
1672
 #endif
 
1673
     bsddb_api.makeDBError      = makeDBError;
 
1674
 
 
1675
     /*
 
1676
-    ** Capsules exist from Python 3.1, but I
 
1677
-    ** don't want to break the API compatibility
 
1678
-    ** for already published Python versions.
 
1679
+    ** Capsules exist from Python 2.7 and 3.1.
 
1680
+    ** We don't support Python 3.0 anymore, so...
 
1681
+    ** #if (PY_VERSION_HEX < ((PY_MAJOR_VERSION < 3) ? 0x02070000 : 0x03020000))
 
1682
     */
 
1683
-#if (PY_VERSION_HEX < 0x03020000)
 
1684
+#if (PY_VERSION_HEX < 0x02070000)
 
1685
     py_api = PyCObject_FromVoidPtr((void*)&bsddb_api, NULL);
 
1686
 #else
 
1687
     {
 
1688
-        char py_api_name[250];
 
1689
+        /*
 
1690
+        ** The data must outlive the call!!. So, the static definition.
 
1691
+        ** The buffer must be big enough...
 
1692
+        */
 
1693
+        static char py_api_name[MODULE_NAME_MAX_LEN+10];
 
1694
 
 
1695
         strcpy(py_api_name, _bsddbModuleName);
 
1696
         strcat(py_api_name, ".api");
 
1697
diff --git a/Modules/bsddb.h b/Modules/bsddb.h
 
1698
index a3a687b..af438bd 100644
 
1699
--- a/Modules/bsddb.h
 
1700
+++ b/Modules/bsddb.h
 
1701
@@ -109,7 +109,7 @@
 
1702
 #error "eek! DBVER can't handle minor versions > 9"
 
1703
 #endif
 
1704
 
 
1705
-#define PY_BSDDB_VERSION "4.8.4.1"
 
1706
+#define PY_BSDDB_VERSION "5.1.2"
 
1707
 
 
1708
 /* Python object definitions */
 
1709
 
 
1710
@@ -236,7 +236,7 @@ typedef struct DBSequenceObject {
 
1711
 /* To access the structure from an external module, use code like the
 
1712
    following (error checking missed out for clarity):
 
1713
 
 
1714
-     // If you are using Python before 3.2:
 
1715
+     // If you are using Python before 2.7:
 
1716
      BSDDB_api* bsddb_api;
 
1717
      PyObject*  mod;
 
1718
      PyObject*  cobj;
 
1719
@@ -249,7 +249,7 @@ typedef struct DBSequenceObject {
 
1720
      Py_DECREF(mod);
 
1721
 
 
1722
 
 
1723
-     // If you are using Python 3.2 or up:
 
1724
+     // If you are using Python 2.7 or up: (except Python 3.0, unsupported)
 
1725
      BSDDB_api* bsddb_api;
 
1726
 
 
1727
      // Use "bsddb3._pybsddb.api" if you're using
 
1728
@@ -257,10 +257,14 @@ typedef struct DBSequenceObject {
 
1729
      bsddb_api = (void **)PyCapsule_Import("bsddb._bsddb.api", 1);
 
1730
 
 
1731
 
 
1732
+   Check "api_version" number before trying to use the API.
 
1733
+
 
1734
    The structure's members must not be changed.
 
1735
 */
 
1736
 
 
1737
+#define PYBSDDB_API_VERSION 1
 
1738
 typedef struct {
 
1739
+    unsigned int api_version;
 
1740
     /* Type objects */
 
1741
     PyTypeObject* db_type;
 
1742
     PyTypeObject* dbcursor_type;
 
1743
@@ -268,9 +272,7 @@ typedef struct {
 
1744
     PyTypeObject* dbenv_type;
 
1745
     PyTypeObject* dbtxn_type;
 
1746
     PyTypeObject* dblock_type;
 
1747
-#if (DBVER >= 43)
 
1748
-    PyTypeObject* dbsequence_type;
 
1749
-#endif
 
1750
+    PyTypeObject* dbsequence_type;  /* If DBVER < 43 -> NULL */
 
1751
 
 
1752
     /* Functions */
 
1753
     int (*makeDBError)(int err);
 
1754
@@ -289,9 +291,9 @@ typedef struct {
 
1755
 #define DBEnvObject_Check(v)    ((v)->ob_type == bsddb_api->dbenv_type)
 
1756
 #define DBTxnObject_Check(v)    ((v)->ob_type == bsddb_api->dbtxn_type)
 
1757
 #define DBLockObject_Check(v)   ((v)->ob_type == bsddb_api->dblock_type)
 
1758
-#if (DBVER >= 43)
 
1759
-#define DBSequenceObject_Check(v)  ((v)->ob_type == bsddb_api->dbsequence_type)
 
1760
-#endif
 
1761
+#define DBSequenceObject_Check(v)  \
 
1762
+    ((bsddb_api->dbsequence_type) && \
 
1763
+        ((v)->ob_type == bsddb_api->dbsequence_type))
 
1764
 
 
1765
 #endif /* COMPILING_BSDDB_C */
 
1766