Commit 24971340 authored by Andreas Tille's avatar Andreas Tille
Browse files

Fix some issues with C++ compatibility of Python3

parent 35e1491b
Loading
Loading
Loading
Loading
+46 −0
Original line number Diff line number Diff line
@@ -14627,3 +14627,49 @@ Last-Update: Thu, 12 Dec 2019 15:41:47 +0100
-Alias('complete-test', testList)
\ No newline at end of file
+Alias('complete-test', testList)
--- a/pdb2pka/substruct/Algorithms.cpp
+++ b/pdb2pka/substruct/Algorithms.cpp
@@ -136,7 +136,7 @@ static PyObject *find_max_clique(PyObjec
 
   for (int i=0; i<cliq.size; i++) {
     cerr << cliq.vertex[i] << " ";
-    PyList_Append(erg, PyInt_FromLong(cliq.vertex[i]));
+    PyList_Append(erg, PyLong_FromLong(cliq.vertex[i]));
   }
   
   for(int i = 0; i < n; i++) {
@@ -242,7 +242,7 @@ static PyObject *find_cliques(PyObject *
     PyObject* cli = PyList_New(0);
 
     for (int j=0; j < collector.cliques[i].size; j++) {
-      PyList_Append(cli, PyInt_FromLong(collector.cliques[i].vertex[j]));
+      PyList_Append(cli, PyLong_FromLong(collector.cliques[i].vertex[j]));
     }
 
     PyList_Append(result, cli);
@@ -299,10 +299,24 @@ static PyMethodDef ModuleMethods[] =   {
 };
 
 /*----------------------------------------------------------------------------*/
+
+// Followed
+//   https://stackoverflow.com/questions/28305731/compiler-cant-find-py-initmodule-is-it-deprecated-and-if-so-what-should-i
+// to replace Py_InitModule
+
+static struct PyModuleDef cModMethods =
+{
+    PyModuleDef_HEAD_INIT,
+    MODULE_STR,  /* name of module */
+    "",          /* module documentation, may be NULL */
+    -1,          /* size of per-interpreter state of the module, or -1 if the module keeps state in global variables. */
+    ModuleMethods
+};
+
 PyMODINIT_FUNC MODULE_INIT()
 {
     
-    PyObject *ThisModule = Py_InitModule( MODULE_STR , ModuleMethods);
+    PyObject *ThisModule = PyModule_Create(&cModMethods);
     PyObject *ModuleDict = PyModule_GetDict(ThisModule);  
 
     // for correct handling of Numpy