diff options
| author | Michael Vogt <michael.vogt@ubuntu.com> | 2006-10-02 18:34:44 +0200 |
|---|---|---|
| committer | Michael Vogt <michael.vogt@ubuntu.com> | 2006-10-02 18:34:44 +0200 |
| commit | 05ac4479d4a37ca55e892c588bcb217fa21ba20a (patch) | |
| tree | 1b1e8a8b75fa6812b12c7cde0e4218db5fa2b82c | |
| parent | 1427f53977faddace94c435f3a6b3c09d9a52660 (diff) | |
| parent | c00b2271e6295c248c18d1bd62e14df372004e85 (diff) | |
| download | python-apt-05ac4479d4a37ca55e892c588bcb217fa21ba20a.tar.gz | |
* merged with python-apt--mvo
| -rw-r--r-- | debian/changelog | 7 | ||||
| -rw-r--r-- | doc/examples/sources.py | 2 | ||||
| -rw-r--r-- | python/progress.cc | 10 | ||||
| -rwxr-xr-x | tests/memleak.py | 14 |
4 files changed, 24 insertions, 9 deletions
diff --git a/debian/changelog b/debian/changelog index 02007000..a0197cb4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.6.19ubuntu6) edgy; urgency=low + + * python/progress.cc: + - fix memleak (lp: #43096) + + -- Michael Vogt <michael.vogt@ubuntu.com> Mon, 2 Oct 2006 18:33:44 +0200 + python-apt (0.6.19ubuntu5) edgy; urgency=low * python/pkgmanager.cc: diff --git a/doc/examples/sources.py b/doc/examples/sources.py index c12c6f15..b48c0ba5 100644 --- a/doc/examples/sources.py +++ b/doc/examples/sources.py @@ -12,4 +12,4 @@ sources.Restart() while sources.Lookup('hello'): print sources.Package, sources.Version, sources.Maintainer, sources.Section, `sources.Binaries` print sources.Files - print sources.Index.ArchiveURI("") + print sources.Index.ArchiveURI(sources.Files[0][2]) diff --git a/python/progress.cc b/python/progress.cc index f00058c9..df9c2ec1 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -18,8 +18,10 @@ bool PyCallbackObj::RunSimpleCallback(const char* method_name, PyObject *arglist, PyObject **res) { - if(callbackInst == 0) + if(callbackInst == 0) { + Py_XDECREF(arglist); return false; + } PyObject *method = PyObject_GetAttrString(callbackInst,(char*) method_name); if(method == NULL) { @@ -49,22 +51,24 @@ bool PyCallbackObj::RunSimpleCallback(const char* method_name, // OpProgress interface -// FIXME: add "string Op, string SubOp" as attribute to the callbackInst void PyOpProgress::Update() { - PyObject *o; o = Py_BuildValue("s", Op.c_str()); PyObject_SetAttrString(callbackInst, "op", o); + Py_XDECREF(o); o = Py_BuildValue("s", SubOp.c_str()); PyObject_SetAttrString(callbackInst, "subOp", o); + Py_XDECREF(o); o = Py_BuildValue("b", MajorChange); PyObject_SetAttrString(callbackInst, "majorChange", o); + Py_XDECREF(o); // Build up the argument list... PyObject *arglist = Py_BuildValue("(f)", Percent); if(CheckChange(0.05)) RunSimpleCallback("update", arglist); + Py_XDECREF(arglist); }; void PyOpProgress::Done() diff --git a/tests/memleak.py b/tests/memleak.py index 3e59cbb7..b5d05afc 100755 --- a/tests/memleak.py +++ b/tests/memleak.py @@ -10,11 +10,15 @@ import sys cache = apt.Cache() # memleak -#for i in range(100): -# cache.open(None) -# print cache["apt"].name -# time.sleep(1) -# gc.collect() +for i in range(100): + cache.open(None) + print cache["apt"].name + time.sleep(1) + gc.collect() + f = open("%s" % i,"w") + for obj in gc.get_objects(): + f.write("%s\n" % str(obj)) + f.close() # memleak #for i in range(100): |
