python/dist/src/Modules _bsddb.c,1.18,1.19
Update of /cvsroot/python/python/dist/src/Modules In directory sc8-pr-cvs1:/tmp/cvs-serv14110/extsrc Modified Files: _bsddb.c Log Message: Adds basic support for BerkeleyDB 4.2.x. Compiles and passes tests; new features in BerkeleyDB not exposed. notably: the DB_MPOOLFILE interface has not yet been wrapped in an object. Adds support for building and installing bsddb3 in python2.3 that has an older version of this module installed as bsddb without conflicts. The pybsddb.sf.net build/packaged version of the module uses a dynamicly loadable module called _pybsddb rather than _bsddb. Index: _bsddb.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_bsddb.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** _bsddb.c 28 Aug 2003 21:50:30 -0000 1.18 --- _bsddb.c 21 Sep 2003 00:08:14 -0000 1.19 *************** *** 37,41 **** * Handwritten code to wrap version 3.x of the Berkeley DB library, * written to replace a SWIG-generated file. It has since been updated ! * to compile with BerkeleyDB versions 3.2 through 4.1. * * This module was started by Andrew Kuchling to remove the dependency --- 37,41 ---- * Handwritten code to wrap version 3.x of the Berkeley DB library, * written to replace a SWIG-generated file. It has since been updated ! * to compile with BerkeleyDB versions 3.2 through 4.2. * * This module was started by Andrew Kuchling to remove the dependency *************** *** 94,98 **** #define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR) ! #define PY_BSDDB_VERSION "4.1.6" static char *rcs_id = "$Id$"; --- 94,98 ---- #define DBVER (DB_VERSION_MAJOR * 10 + DB_VERSION_MINOR) ! #define PY_BSDDB_VERSION "4.2.0" static char *rcs_id = "$Id$"; *************** *** 2168,2171 **** --- 2168,2182 ---- if (outFileName) fclose(outFile); + + /* DB.verify acts as a DB handle destructor (like close); this was + * documented in BerkeleyDB 4.2 but had the undocumented effect + * of not being safe in prior versions while still requiring an explicit + * DB.close call afterwards. Lets call close for the user to emulate + * the safe 4.2 behaviour. */ + #if (DBVER <= 41) + self->db->close(self->db, 0); + #endif + self->db = NULL; + RETURN_IF_ERR(); RETURN_NONE(); *************** *** 4341,4345 **** #define ADD_INT(dict, NAME) _addIntToDict(dict, #NAME, NAME) ! DL_EXPORT(void) init_bsddb(void) --- 4352,4357 ---- #define ADD_INT(dict, NAME) _addIntToDict(dict, #NAME, NAME) ! #define MODULE_NAME_MAX_LEN 11 ! static char _bsddbModuleName[MODULE_NAME_MAX_LEN+1] = "_bsddb"; DL_EXPORT(void) init_bsddb(void) *************** *** 4366,4370 **** /* Create the module and add the functions */ ! m = Py_InitModule("_bsddb", bsddb_methods); /* Add some symbolic constants to the module */ --- 4378,4382 ---- /* Create the module and add the functions */ ! m = Py_InitModule(_bsddbModuleName, bsddb_methods); /* Add some symbolic constants to the module */ *************** *** 4387,4391 **** --- 4399,4409 ---- ADD_INT(d, DB_MAX_RECORDS); + #if (DBVER >= 42) + ADD_INT(d, DB_RPCCLIENT); + #else ADD_INT(d, DB_CLIENT); + /* allow apps to be written using DB_RPCCLIENT on older BerkeleyDB */ + _addIntToDict(d, "DB_RPCCLIENT", DB_CLIENT); + #endif ADD_INT(d, DB_XA_CREATE); *************** *** 4536,4540 **** ADD_INT(d, DB_CURLSN); #endif ! #if (DBVER >= 33) ADD_INT(d, DB_COMMIT); #endif --- 4554,4558 ---- ADD_INT(d, DB_CURLSN); #endif ! #if ((DBVER >= 33) && (DBVER <= 41)) ADD_INT(d, DB_COMMIT); #endif *************** *** 4611,4614 **** --- 4629,4644 ---- #endif + #if (DBVER >= 42) + ADD_INT(d, DB_TIME_NOTGRANTED); + ADD_INT(d, DB_TXN_NOT_DURABLE); + ADD_INT(d, DB_TXN_WRITE_NOSYNC); + ADD_INT(d, DB_LOG_AUTOREMOVE); + ADD_INT(d, DB_DIRECT_LOG); + ADD_INT(d, DB_DIRECT_DB); + ADD_INT(d, DB_INIT_REP); + ADD_INT(d, DB_ENCRYPT); + ADD_INT(d, DB_CHKSUM); + #endif + #if (DBVER >= 41) ADD_INT(d, DB_ENCRYPT_AES); *************** *** 4686,4688 **** --- 4716,4727 ---- Py_FatalError("can't initialize module _bsddb"); } + } + + /* allow this module to be named _pybsddb so that it can be installed + * and imported on top of python >= 2.3 that includes its own older + * copy of the library named _bsddb without importing the old version. */ + DL_EXPORT(void) init_pybsddb(void) + { + strncpy(_bsddbModuleName, "_pybsddb", MODULE_NAME_MAX_LEN); + init_bsddb(); }
participants (1)
-
gregļ¼ users.sourceforge.net