Commit 0c635c2a authored by Kipp Cannon's avatar Kipp Cannon

ilwd.c tokenizer.c: fix building w/ Python 2.7

parent bb9272a9
......@@ -463,20 +463,19 @@ PyMODINIT_FUNC PyInit__ilwd(void); /* Silence -Wmissing-prototypes */
PyMODINIT_FUNC PyInit__ilwd(void)
#endif
{
static PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
MODULE_NAME, MODULE_DOC, -1, NULL
};
PyObject *module = NULL;
if(PyType_Ready(&ligolw_ilwdchar_Type) < 0)
goto done;
/*
* Create the module.
*/
module = PyModule_Create(&moduledef);
#if PY_MAJOR_VERSION < 3
PyObject *module = Py_InitModule3(MODULE_NAME, NULL, MODULE_DOC);
#else
static PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
MODULE_NAME, MODULE_DOC, -1, NULL
};
PyObject *module = PyModule_Create(&moduledef);
#endif
if (!module)
goto done;
......@@ -484,6 +483,8 @@ PyMODINIT_FUNC PyInit__ilwd(void)
* Add the ilwdchar class.
*/
if(PyType_Ready(&ligolw_ilwdchar_Type) < 0)
goto done;
Py_INCREF(&ligolw_ilwdchar_Type);
PyModule_AddObject(module, "ilwdchar", (PyObject *) &ligolw_ilwdchar_Type);
......
......@@ -118,11 +118,25 @@ PyMODINIT_FUNC PyInit_tokenizer(void); /* Silence -Wmissing-prototypes */
PyMODINIT_FUNC PyInit_tokenizer(void)
#endif
{
/*
* Create the module.
*/
#if PY_MAJOR_VERSION < 3
PyObject *module = Py_InitModule3(MODULE_NAME, NULL, MODULE_DOC);
#else
static PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
MODULE_NAME, MODULE_DOC, -1, NULL
};
PyObject *module = NULL;
PyObject *module = PyModule_Create(&moduledef);
#endif
if (!module)
goto done;
/*
* Initialize the classes
*/
if(PyType_Ready(&ligolw_Tokenizer_Type) < 0)
goto done;
......@@ -131,14 +145,6 @@ PyMODINIT_FUNC PyInit_tokenizer(void)
if(PyType_Ready(&ligolw_RowDumper_Type) < 0)
goto done;
/*
* Create the module.
*/
module = PyModule_Create(&moduledef);
if (!module)
goto done;
/*
* Add the Tokenizer class.
*/
......@@ -160,6 +166,10 @@ PyMODINIT_FUNC PyInit_tokenizer(void)
Py_INCREF(&ligolw_RowDumper_Type);
PyModule_AddObject(module, "RowDumper", (PyObject *) &ligolw_RowDumper_Type);
/*
* Done.
*/
done:
#if PY_MAJOR_VERSION < 3
return;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment