summaryrefslogtreecommitdiffstats
path: root/Modules/_sqlite/module.c
diff options
context:
space:
mode:
authorMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
committerMartin v. Löwis <martin@v.loewis.de>2008-06-11 05:26:20 (GMT)
commit1a21451b1d73b65af949193208372e86bf308411 (patch)
tree8e98d7be9e249b011ae9380479656e5284ec0234 /Modules/_sqlite/module.c
parentcdf94635d7e364f9ce1905bafa5b540f4d16147c (diff)
downloadcpython-1a21451b1d73b65af949193208372e86bf308411.zip
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.gz
cpython-1a21451b1d73b65af949193208372e86bf308411.tar.bz2
Implement PEP 3121: new module initialization and finalization API.
Diffstat (limited to 'Modules/_sqlite/module.c')
-rw-r--r--Modules/_sqlite/module.c23
1 files changed, 20 insertions, 3 deletions
diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c
index 1f8c63f..59d0d17 100644
--- a/Modules/_sqlite/module.c
+++ b/Modules/_sqlite/module.c
@@ -257,13 +257,26 @@ static IntConstantPair _int_constants[] = {
{(char*)NULL, 0}
};
-PyMODINIT_FUNC init_sqlite3(void)
+
+static struct PyModuleDef _sqlite3module = {
+ PyModuleDef_HEAD_INIT,
+ "_sqlite3",
+ NULL,
+ -1,
+ module_methods,
+ NULL,
+ NULL,
+ NULL,
+ NULL
+};
+
+PyMODINIT_FUNC PyInit__sqlite3(void)
{
PyObject *module, *dict;
PyObject *tmp_obj;
int i;
- module = Py_InitModule("_sqlite3", module_methods);
+ module = PyModule_Create(&_sqlite3module);
if (!module ||
(pysqlite_row_setup_types() < 0) ||
@@ -273,7 +286,8 @@ PyMODINIT_FUNC init_sqlite3(void)
(pysqlite_statement_setup_types() < 0) ||
(pysqlite_prepare_protocol_setup_types() < 0)
) {
- return;
+ Py_DECREF(module);
+ return NULL;
}
Py_INCREF(&pysqlite_ConnectionType);
@@ -408,5 +422,8 @@ error:
if (PyErr_Occurred())
{
PyErr_SetString(PyExc_ImportError, MODULE_NAME ": init failed");
+ Py_DECREF(module);
+ module = NULL;
}
+ return module;
}