summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--debian/changelog18
-rw-r--r--doc/examples/depcache.py1
-rw-r--r--python/cache.cc11
-rw-r--r--python/depcache.cc31
4 files changed, 42 insertions, 19 deletions
diff --git a/debian/changelog b/debian/changelog
index 10e5cda2..0c8c9431 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,21 @@
+python-apt (0.5.36ubuntu4) hoary; urgency=low
+
+ * fixed some reference count problems in the depcache code
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Thu, 31 Mar 2005 13:15:50 +0200
+
+python-apt (0.5.36ubuntu3) hoary; urgency=low
+
+ * DepCache.Init() is never called implicit now
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Wed, 23 Mar 2005 15:24:56 +0100
+
+python-apt (0.5.36ubuntu2) hoary; urgency=low
+
+ * return "None" in GetCandidateVer() if no Candidate is found
+
+ -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 15 Mar 2005 12:30:06 +0100
+
python-apt (0.5.36ubuntu1) hoary; urgency=low
* DepCache.ReadPinFile() added
diff --git a/doc/examples/depcache.py b/doc/examples/depcache.py
index baf2d875..0eb2f075 100644
--- a/doc/examples/depcache.py
+++ b/doc/examples/depcache.py
@@ -34,6 +34,7 @@ print "example package iter: %s" % iter
print "\n\n depcache"
depcache = apt_pkg.GetDepCache(cache, progress)
depcache.ReadPinFile()
+# init is needed after the creation/pin file reading
print "got a depcache: %s " % depcache
print "Marked for install: %s " % depcache.InstCount
diff --git a/python/cache.cc b/python/cache.cc
index 9ad558da..126ab15d 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -20,9 +20,16 @@
#include <Python.h>
#include "progress.h"
-#include "cache.h"
- /*}}}*/
+ /*}}}*/
+struct PkgListStruct
+{
+ pkgCache::PkgIterator Iter;
+ unsigned long LastIndex;
+
+ PkgListStruct(pkgCache::PkgIterator const &I) : Iter(I), LastIndex(0) {}
+ PkgListStruct() {abort();}; // G++ Bug..
+};
struct RDepListStruct
{
diff --git a/python/depcache.cc b/python/depcache.cc
index 9c302b40..dcccf75c 100644
--- a/python/depcache.cc
+++ b/python/depcache.cc
@@ -21,7 +21,6 @@
#include <iostream>
#include "progress.h"
-#include "cache.h"
// DepCache Class /*{{{*/
// ---------------------------------------------------------------------
@@ -62,6 +61,7 @@ static PyObject *PkgDepCacheInit(PyObject *Self,PyObject *Args)
Struct.depcache->Init(0);
}
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -75,6 +75,10 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args)
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj);
pkgCache::VerIterator I = Struct.depcache->GetCandidateVer(Pkg);
+ if(I.end()) {
+ Py_INCREF(Py_None);
+ return Py_None;
+ }
CandidateObj = CppOwnedPyObject_NEW<pkgCache::VerIterator>(PackageObj,&VersionType,I);
return CandidateObj;
@@ -93,6 +97,7 @@ static PyObject *PkgDepCacheUpgrade(PyObject *Self,PyObject *Args)
else
pkgAllUpgrade(*Struct.depcache);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -104,11 +109,12 @@ static PyObject *PkgDepCacheReadPinFile(PyObject *Self,PyObject *Args)
if (PyArg_ParseTuple(Args,"|s",&file) == 0)
return 0;
- if(file == NULL)
+ if(file == NULL)
ReadPinFile(*Struct.policy);
else
ReadPinFile(*Struct.policy, file);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -122,6 +128,7 @@ static PyObject *PkgDepCacheFixBroken(PyObject *Self,PyObject *Args)
pkgFixBroken(*Struct.depcache);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -137,6 +144,7 @@ static PyObject *PkgDepCacheMarkKeep(PyObject *Self,PyObject *Args)
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj);
Struct.depcache->MarkKeep(Pkg);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -152,6 +160,7 @@ static PyObject *PkgDepCacheMarkDelete(PyObject *Self,PyObject *Args)
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj);
Struct.depcache->MarkDelete(Pkg,purge);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -166,6 +175,7 @@ static PyObject *PkgDepCacheMarkInstall(PyObject *Self,PyObject *Args)
pkgCache::PkgIterator &Pkg = GetCpp<pkgCache::PkgIterator>(PackageObj);
Struct.depcache->MarkInstall(Pkg);
+ Py_INCREF(Py_None);
return HandleErrors(Py_None);
}
@@ -296,12 +306,8 @@ static PyObject *DepCacheAttr(PyObject *Self,char *Name)
{
PkgDepCacheStruct &Struct = GetCpp<PkgDepCacheStruct>(Self);
- // look like a cache
- if (strcmp("Packages",Name) == 0)
- return CppOwnedPyObject_NEW<PkgListStruct>(Self,&PkgListType,
- Struct.depcache->PkgBegin());
// size querries
- else if(strcmp("KeepCount",Name) == 0)
+ if(strcmp("KeepCount",Name) == 0)
return Py_BuildValue("l", Struct.depcache->KeepCount());
else if(strcmp("InstCount",Name) == 0)
return Py_BuildValue("l", Struct.depcache->InstCount());
@@ -345,8 +351,7 @@ PyTypeObject PkgDepCacheType =
PyObject *GetDepCache(PyObject *Self,PyObject *Args)
{
PyObject *Owner;
- PyObject *pyCallbackInst = 0;
- if (PyArg_ParseTuple(Args,"O!|O",&PkgCacheType,&Owner,&pyCallbackInst) == 0)
+ if (PyArg_ParseTuple(Args,"O!",&PkgCacheType,&Owner) == 0)
return 0;
PyObject *DepCachePyObj;
@@ -356,14 +361,6 @@ PyObject *GetDepCache(PyObject *Self,PyObject *Args)
HandleErrors(DepCachePyObj);
PkgDepCacheStruct &Struct = GetCpp<PkgDepCacheStruct>(DepCachePyObj);
- if(pyCallbackInst != 0) {
- PyOpProgress progress;
- progress.setCallbackInst(pyCallbackInst);
- Struct.depcache->Init(&progress);
- } else {
- Struct.depcache->Init(0);
- }
-
return DepCachePyObj;
}