diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-04-15 16:19:12 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-04-15 16:19:12 +0200 |
| commit | c876c5095673a2f1c0f2c0eef6eadef2ce200e19 (patch) | |
| tree | f0832dbbdeb688e0176294e9b487f996108555ad /python/apt_instmodule.cc | |
| parent | 97d985d73d12da5578628418aa787d78a33b652d (diff) | |
| download | python-apt-c876c5095673a2f1c0f2c0eef6eadef2ce200e19.tar.gz | |
* Introduce support for Python 3 (Closes: #523645)
This is the first initial port to Python 3. The API is almost completely
identical to the one found in Python 2, except that functions working with
binary data require bytes (md5sum,sha1sum,sha256sum,Base64Encode).
Using setup3.py to install the modules will not work, because the apt package
still has to be converted to Python 3. For the package, we call 2to3-3.1 in
debian/rules to do this automatically.
Diffstat (limited to 'python/apt_instmodule.cc')
| -rw-r--r-- | python/apt_instmodule.cc | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index a9d81be4..09e3937e 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -162,8 +162,41 @@ static PyMethodDef methods[] = {} }; +#if PY_MAJOR_VERSION >= 3 +struct module_state { + PyObject *error; +}; +#define GETSTATE(m) ((struct module_state*)PyModule_GetState(m)) + +static int apt_inst_traverse(PyObject *m, visitproc visit, void *arg) { + Py_VISIT(GETSTATE(m)->error); + return 0; +} + +static int apt_inst_clear(PyObject *m) { + Py_CLEAR(GETSTATE(m)->error); + return 0; +} + +static struct PyModuleDef moduledef = { + PyModuleDef_HEAD_INIT, + "apt_inst", + NULL, + sizeof(struct module_state), + methods, + NULL, + apt_inst_traverse, + apt_inst_clear, + NULL +}; + +extern "C" PyObject * PyInit_apt_inst() +{ + return PyModule_Create(&moduledef); +} +#else extern "C" void initapt_inst() { Py_InitModule("apt_inst",methods); } - /*}}}*/ +#endif /*}}}*/ |
