This commit is contained in:
Kovid Goyal 2019-02-27 05:44:53 +05:30
commit e3f51686ee
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -263,6 +263,8 @@ sqlite_custom_init_funcs(PyObject *self, PyObject *args) {
Py_RETURN_NONE;
}
static char sqlite_custom_doc[] = "Implementation of custom sqlite methods in C for speed.";
static PyMethodDef sqlite_custom_methods[] = {
{"init_funcs", sqlite_custom_init_funcs, METH_VARARGS,
"init_funcs()\n\nInitialize module."
@ -271,11 +273,33 @@ static PyMethodDef sqlite_custom_methods[] = {
{NULL, NULL, 0, NULL}
};
CALIBRE_MODINIT_FUNC
initsqlite_custom(void) {
#if PY_MAJOR_VERSION >= 3
#define INITERROR return NULL
#define INITMODULE PyModule_Create(&sqlite_custom_module)
static struct PyModuleDef sqlite_custom_module = {
/* m_base */ PyModuleDef_HEAD_INIT,
/* m_name */ "sqlite_custom",
/* m_doc */ sqlite_custom_doc,
/* m_size */ -1,
/* m_methods */ sqlite_custom_methods,
/* m_slots */ 0,
/* m_traverse */ 0,
/* m_clear */ 0,
/* m_free */ 0,
};
CALIBRE_MODINIT_FUNC PyInit_sqlite_custom(void) {
#else
#define INITERROR return
#define INITMODULE Py_InitModule3("sqlite_custom", sqlite_custom_methods, sqlite_custom_doc)
CALIBRE_MODINIT_FUNC initsqlite_custom(void) {
#endif
PyObject *m;
m = Py_InitModule3("sqlite_custom", sqlite_custom_methods,
"Implementation of custom sqlite methods in C for speed."
);
if (m == NULL) return;
m = INITMODULE;
if (m == NULL) {
INITERROR;
}
#if PY_MAJOR_VERSION >= 3
return m;
#endif
}