From 7c248775da6c86e70a8444630722c92a2dcd676f Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 22 Jun 2009 15:53:45 +0200 Subject: python/cache.cc: Drop apt_pkg.Cache.open() and apt_pkg.Cache.close(). Drop these functions, because they cause segfaults and memory leaks. To replace this functionality, simply create/delete a Cache object. This way, reference counting can work. --- debian/changelog | 4 +++- python/cache.cc | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/debian/changelog b/debian/changelog index f0b3efbe..0ef7e38b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -15,6 +15,8 @@ python-apt (0.7.92) UNRELEASED; urgency=low open() (LP: #320665). * Add apt_pkg.DepCache.mark_auto() and apt.Package.mark_auto() methods to mark a package as automatically installed. + * Drop apt_pkg.Cache.open() and apt_pkg.Cache.close(), they cause segfaults + and memory leaks. Simply create a new cache instead. [ Sebastian Heinlein ] * apt/progress.py: Extract the package name from the status message @@ -30,7 +32,7 @@ python-apt (0.7.92) UNRELEASED; urgency=low * python/progress.cc: - low level code for update_status_full and pulse_items() - -- Julian Andres Klode Mon, 22 Jun 2009 14:38:19 +0200 + -- Julian Andres Klode Mon, 22 Jun 2009 15:49:03 +0200 python-apt (0.7.91) experimental; urgency=low diff --git a/python/cache.cc b/python/cache.cc index 4624dc34..4ce3178c 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -95,6 +95,8 @@ static PyObject *PkgCacheUpdate(PyObject *Self,PyObject *Args) static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Close() is deprecated, " + "because it causes segfaults. Delete the Cache instead.", 1); PyObject *CacheFilePy = GetOwner(Self); pkgCacheFile *Cache = GetCpp(CacheFilePy); Cache->Close(); @@ -105,6 +107,9 @@ static PyObject *PkgCacheClose(PyObject *Self,PyObject *Args) static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args) { + PyErr_WarnEx(PyExc_DeprecationWarning, "Cache.Open() is deprecated, " + "because it causes memory leaks. Create a new Cache instead.", + 1); PyObject *CacheFilePy = GetOwner(Self); pkgCacheFile *Cache = GetCpp(CacheFilePy); @@ -137,8 +142,6 @@ static PyObject *PkgCacheOpen(PyObject *Self,PyObject *Args) static PyMethodDef PkgCacheMethods[] = { {"update",PkgCacheUpdate,METH_VARARGS,"Update the cache"}, - {"open", PkgCacheOpen, METH_VARARGS,"Open the cache"}, - {"close", PkgCacheClose, METH_VARARGS,"Close the cache"}, #ifdef COMPAT_0_7 {"Update",PkgCacheUpdate,METH_VARARGS,"Update the cache"}, {"Open", PkgCacheOpen, METH_VARARGS,"Open the cache"}, -- cgit v1.2.3