Open ghost opened 8 years ago
To make pylirc work with python3 I added at then end of pylircmodule.c file
struct module_state { PyObject *error; };
static int pylircTraverse(PyObject m, visitproc visit, void arg) { Py_VISIT(GETSTATE(m)->error); return 0; }
static int pylircClear(PyObject *m) { Py_CLEAR(GETSTATE(m)->error); return 0; }
static struct PyModuleDef moduledef = { PyModuleDef_HEAD_INIT, "pylirc", NULL, sizeof(struct module_state), pylircMethods, NULL, pylircTraverse, pylircClear, NULL };
PyObject * PyInit_pylirc(void) { PyObject module = PyModule_Create(&moduledef); if (module == NULL) return NULL; struct module_state st = GETSTATE(module);
st->error = PyErr_NewException("pylirc.Error", NULL, NULL);
if (st->error == NULL) {
Py_DECREF(module);
return NULL;
}
return module;
}
And you there is a need to avoid warning pylircmodule.c:271:5: warning: implicit declaration of function ‘Py_InitModule’ [-Wimplicit-function-declaration] place // Python init function void initpylirc(void) { (void) Py_InitModule("pylirc", pylircMethods); } to else at the end like this
... return module; }
// Python init function void initpylirc(void) { (void) Py_InitModule("pylirc", pylircMethods); }
For me this is work on raspbian
lsb_release -a No LSB modules are available. Distributor ID: Raspbian Description: Raspbian GNU/Linux 8.0 (jessie) Release: 8.0 Codename: jessie
But also there is a need to rename /usr/local/lib/python3.4/dist-packages/pylircmodule.cpython-34m.so -> /usr/local/lib/python3.4/dist-packages/pylirc.cpython-34m.so
Could you please clone the repository and commit your changes? I tried to follow the changes you described, however I don't understand what you mean in the section about "avoid warning pylircmodule.c:271:5:".
Hello! Thank you for pylirc. Do you have any plans to support pylirc for python3? Now pylirc is not loadable. I am not an expert of python. But I think it is because Py_InitModule() does not exist in python3. PyModule_Create() should be used instead. https://docs.python.org/3/howto/cporting.html I have installed pylirc as pip3 install pylirc2. Got an error python3 -c 'import pylirc'", line 1, in
ImportError: No module named 'pylirc'
Traceback (most recent call last): File "
with -v option Traceback (most recent call last): File "", line 1, in
File "", line 2237, in _find_and_load
File "", line 2224, in _find_and_load_unlocked
ImportError: No module named 'pylirc'
if I rename /usr/local/lib/python3.4/dist-packages/pylircmodule.cpython-34m.so to /usr/local/lib/python3.4/dist-packages/pylirc.cpython-34m.so
Then I got
python3 -c 'import pylirc'", line 1, in
ImportError: /usr/local/lib/python3.4/dist-packages/pylirc.cpython-34m.so: undefined symbol: Py_InitModule
Traceback (most recent call last): File "