diff options
| author | Julian Andres Klode <jak@debian.org> | 2009-07-22 17:21:08 +0200 |
|---|---|---|
| committer | Julian Andres Klode <jak@debian.org> | 2009-07-22 17:21:08 +0200 |
| commit | 6ba42d2e31f161fc0ebe5405cf63b616c3e822b4 (patch) | |
| tree | e9083ea32a3dd8940de54c3d529d646d6fa3f751 /python/progress.cc | |
| parent | 8e6ce0ce4761404cf13bea468d925fc906ab2143 (diff) | |
| download | python-apt-6ba42d2e31f161fc0ebe5405cf63b616c3e822b4.tar.gz | |
python: First step of fixing acquire stuff.
Basically, we only want to have on PyAcquireItem per pkgAcquire::Item,
and one PyAcquireItemDesc per pkgAcquire::ItemDesc. Therefore, we store
them so we can return them at a later time.
Diffstat (limited to 'python/progress.cc')
| -rw-r--r-- | python/progress.cc | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/python/progress.cc b/python/progress.cc index 305246b7..1b135a75 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -35,7 +35,12 @@ inline bool setattr(PyObject *object, const char *attr, const char *fmt, T arg) return result != -1; } -#define TUPLEIZE(op) Py_BuildValue("(O)", op) +inline PyObject *TUPLEIZE(PyObject *op) { + PyObject *ret = Py_BuildValue("(O)", op); + Py_DECREF(op); + return ret; +} + // generic bool PyCallbackObj::RunSimpleCallback(const char* method_name, PyObject *arglist, @@ -300,7 +305,10 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) if (PyObject_TypeCheck(callbackInst, &PyAcquireProgress_Type)) { PyObject *result1; bool res1 = true; - if (RunSimpleCallback("pulse", TUPLEIZE(PyAcquire_FromCpp(Owner)), &result1)) { + + Py_INCREF(pyAcquire); + + if (RunSimpleCallback("pulse", TUPLEIZE(pyAcquire) , &result1)) { if (result1 != NULL && PyArg_Parse(result1, "b", &res1) && res1 == false) { // the user returned a explicit false here, stop PyCbObj_BEGIN_ALLOW_THREADS |
