Verified Commit ddf6426b authored by Štěpán Henek's avatar Štěpán Henek 🌩

migrate to python3

parent 60222da1
Pipeline #41799 failed with stages
in 56 seconds
......@@ -148,6 +148,48 @@ static PyMethodDef atsha_methods[] = {
{NULL}
};
PyMODINIT_FUNC initatsha204(void) {
Py_InitModule("atsha204", atsha_methods);
struct module_state {
PyObject *error;
};
#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m))
static int atsha_traverse(PyObject *m, visitproc visit, void *arg) {
Py_VISIT(GETSTATE(m)->error);
return 0;
}
static int atsha_clear(PyObject *m) {
Py_CLEAR(GETSTATE(m)->error);
return 0;
}
static struct PyModuleDef moduledef = {
PyModuleDef_HEAD_INIT,
"atsha204",
NULL,
sizeof(struct module_state),
atsha_methods,
NULL,
atsha_traverse,
atsha_clear,
NULL
};
PyMODINIT_FUNC
PyInit_atsha204(void)
{
PyObject *module = PyModule_Create(&moduledef);
if (module == NULL) {
return NULL;
}
struct module_state *st = GETSTATE(module);
st->error = PyErr_NewException("atsha204.Error", NULL, NULL);
if (st->error == NULL) {
Py_DECREF(module);
return NULL;
}
return module;
}
......@@ -18,4 +18,4 @@
from distutils.core import setup, Extension
extension = Extension('atsha204', ['atsha204.c'], libraries=['atsha204'], library_dirs=['../../lib'])
setup(name='atsha204', version='0.1', ext_modules=[extension], provides=['atsha204'])
setup(name='atsha204', version='0.2', ext_modules=[extension], provides=['atsha204'])
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