Support linking of the bsddb module against BerkeleyDB 4.5.x
(will backport to 2.5)
diff --git a/Doc/lib/libbsddb.tex b/Doc/lib/libbsddb.tex
index 85ea824..e9d7e21 100644
--- a/Doc/lib/libbsddb.tex
+++ b/Doc/lib/libbsddb.tex
@@ -16,7 +16,7 @@
 \function{pickle.dumps()}.
 
 The \module{bsddb} module requires a Berkeley DB library version from
-3.3 thru 4.4.
+3.3 thru 4.5.
 
 \begin{seealso}
   \seeurl{http://pybsddb.sourceforge.net/}
diff --git a/Lib/bsddb/dbobj.py b/Lib/bsddb/dbobj.py
index 73a3010..b74ee72 100644
--- a/Lib/bsddb/dbobj.py
+++ b/Lib/bsddb/dbobj.py
@@ -55,8 +55,9 @@
         return apply(self._cobj.set_lg_max, args, kwargs)
     def set_lk_detect(self, *args, **kwargs):
         return apply(self._cobj.set_lk_detect, args, kwargs)
-    def set_lk_max(self, *args, **kwargs):
-        return apply(self._cobj.set_lk_max, args, kwargs)
+    if db.version() < (4,5):
+        def set_lk_max(self, *args, **kwargs):
+            return apply(self._cobj.set_lk_max, args, kwargs)
     def set_lk_max_locks(self, *args, **kwargs):
         return apply(self._cobj.set_lk_max_locks, args, kwargs)
     def set_lk_max_lockers(self, *args, **kwargs):
diff --git a/Lib/bsddb/test/test_1413192.py b/Lib/bsddb/test/test_1413192.py
index 3c13536..436f407 100644
--- a/Lib/bsddb/test/test_1413192.py
+++ b/Lib/bsddb/test/test_1413192.py
@@ -14,7 +14,7 @@
 env_name = '.'
 
 env = db.DBEnv()
-env.open(env_name, db.DB_CREATE | db.DB_INIT_TXN)
+env.open(env_name, db.DB_CREATE | db.DB_INIT_TXN | db.DB_INIT_MPOOL)
 the_txn = env.txn_begin()
 
 map = db.DB(env)
diff --git a/Misc/NEWS b/Misc/NEWS
index 972f1e0..f3749ab 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -322,6 +322,8 @@
   been defined.  This prevents an interactive Python from waking up 10
   times per second.  Patch by Richard Boulton.
 
+- Added support for linking the bsddb module against BerkeleyDB 4.5.x.
+
 
 Tests
 -----
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c
index e6046e7..13b5b7b 100644
--- a/Modules/_bsddb.c
+++ b/Modules/_bsddb.c
@@ -4127,6 +4127,7 @@
 }
 
 
+#if (DBVER < 45)
 static PyObject*
 DBEnv_set_lk_max(DBEnvObject* self, PyObject* args)
 {
@@ -4142,6 +4143,7 @@
     RETURN_IF_ERR();
     RETURN_NONE();
 }
+#endif
 
 
 #if (DBVER >= 32)
@@ -5231,7 +5233,9 @@
     {"set_lg_regionmax",(PyCFunction)DBEnv_set_lg_regionmax, METH_VARARGS},
 #endif
     {"set_lk_detect",   (PyCFunction)DBEnv_set_lk_detect,    METH_VARARGS},
+#if (DBVER < 45)
     {"set_lk_max",      (PyCFunction)DBEnv_set_lk_max,       METH_VARARGS},
+#endif
 #if (DBVER >= 32)
     {"set_lk_max_locks", (PyCFunction)DBEnv_set_lk_max_locks, METH_VARARGS},
     {"set_lk_max_lockers", (PyCFunction)DBEnv_set_lk_max_lockers, METH_VARARGS},
@@ -5833,7 +5837,9 @@
     ADD_INT(d, DB_AFTER);
     ADD_INT(d, DB_APPEND);
     ADD_INT(d, DB_BEFORE);
+#if (DBVER < 45)
     ADD_INT(d, DB_CACHED_COUNTS);
+#endif
 #if (DBVER >= 41)
     _addIntToDict(d, "DB_CHECKPOINT", 0);
 #else
@@ -5868,7 +5874,9 @@
     ADD_INT(d, DB_POSITION);
     ADD_INT(d, DB_PREV);
     ADD_INT(d, DB_PREV_NODUP);
+#if (DBVER < 45)
     ADD_INT(d, DB_RECORDCOUNT);
+#endif
     ADD_INT(d, DB_SET);
     ADD_INT(d, DB_SET_RANGE);
     ADD_INT(d, DB_SET_RECNO);
diff --git a/setup.py b/setup.py
index bf649fe..c1d5f00 100644
--- a/setup.py
+++ b/setup.py
@@ -606,7 +606,7 @@
         # a release.  Most open source OSes come with one or more
         # versions of BerkeleyDB already installed.
 
-        max_db_ver = (4, 4)
+        max_db_ver = (4, 5)
         min_db_ver = (3, 3)
         db_setup_debug = False   # verbose debug prints from this script?
 
@@ -623,7 +623,7 @@
             '/sw/include/db3',
         ]
         # 4.x minor number specific paths
-        for x in (0,1,2,3,4):
+        for x in (0,1,2,3,4,5):
             db_inc_paths.append('/usr/include/db4%d' % x)
             db_inc_paths.append('/usr/include/db4.%d' % x)
             db_inc_paths.append('/usr/local/BerkeleyDB.4.%d/include' % x)
@@ -631,7 +631,7 @@
             db_inc_paths.append('/pkg/db-4.%d/include' % x)
             db_inc_paths.append('/opt/db-4.%d/include' % x)
         # 3.x minor number specific paths
-        for x in (2,3):
+        for x in (3,):
             db_inc_paths.append('/usr/include/db3%d' % x)
             db_inc_paths.append('/usr/local/BerkeleyDB.3.%d/include' % x)
             db_inc_paths.append('/usr/local/include/db3%d' % x)