diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2008-06-11 05:26:20 (GMT) |
commit | 1a21451b1d73b65af949193208372e86bf308411 (patch) | |
tree | 8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/_bsddb.c | |
parent | cdf94635d7e364f9ce1905bafa5b540f4d16147c (diff) | |
download | cpython-1a21451b1d73b65af949193208372e86bf308411.zip cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2 |
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/_bsddb.c')
-rw-r--r-- | Modules/_bsddb.c | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/Modules/_bsddb.c b/Modules/_bsddb.c index 9e31029..6b543fd 100644 --- a/Modules/_bsddb.c +++ b/Modules/_bsddb.c @@ -5646,7 +5646,20 @@ static BSDDB_api bsddb_api; #define MODULE_NAME_MAX_LEN 11 static char _bsddbModuleName[MODULE_NAME_MAX_LEN+1] = "_bsddb"; -PyMODINIT_FUNC init_bsddb(void) + +static struct PyModuleDef _bsddbmodule = { + PyModuleDef_HEAD_INIT, + _bsddbModuleName, + NULL, + -1, + bsddb_methods, + NULL, + NULL, + NULL, + NULL +}; + +PyMODINIT_FUNC PyInit__bsddb(void) { PyObject* m; PyObject* d; @@ -5673,9 +5686,9 @@ PyMODINIT_FUNC init_bsddb(void) #endif /* Create the module and add the functions */ - m = Py_InitModule(_bsddbModuleName, bsddb_methods); + m = PyModule_Create(&_bsddbmodule); if (m == NULL) - return; + return NULL; /* Add some symbolic constants to the module */ d = PyModule_GetDict(m); @@ -6064,7 +6077,10 @@ PyMODINIT_FUNC init_bsddb(void) if (PyErr_Occurred()) { PyErr_Print(); Py_FatalError("can't initialize module _bsddb"); + Py_DECREF(m); + m = NULL; } + return m; } /* allow this module to be named _pybsddb so that it can be installed @@ -6073,5 +6089,5 @@ PyMODINIT_FUNC init_bsddb(void) PyMODINIT_FUNC init_pybsddb(void) { strncpy(_bsddbModuleName, "_pybsddb", MODULE_NAME_MAX_LEN); - init_bsddb(); + return PyInit__bsddb(); } |