summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
Diffstat (limited to 'python')
-rw-r--r--python/depcache.cc6
-rw-r--r--python/generic.h11
-rw-r--r--python/pkgsrcrecords.cc13
-rw-r--r--python/sourcelist.cc4
4 files changed, 25 insertions, 9 deletions
diff --git a/python/depcache.cc b/python/depcache.cc
index ae6da3b9..d2ec4a8d 100644
--- a/python/depcache.cc
+++ b/python/depcache.cc
@@ -43,9 +43,6 @@ struct PkgDepCacheStruct
delete depcache;
delete policy;
};
-
-
- PkgDepCacheStruct() {abort();};
};
@@ -439,11 +436,10 @@ static PyMethodDef PkgDepCacheMethods[] =
{"MarkedInstall",PkgDepCacheMarkedInstall,METH_VARARGS,"Is pkg marked for install"},
{"MarkedUpgrade",PkgDepCacheMarkedUpgrade,METH_VARARGS,"Is pkg marked for upgrade"},
{"MarkedDelete",PkgDepCacheMarkedDelete,METH_VARARGS,"Is pkg marked for delete"},
- {"MarkedKeep",PkgDepCacheMarkedDelete,METH_VARARGS,"Is pkg marked for keep"},
+ {"MarkedKeep",PkgDepCacheMarkedKeep,METH_VARARGS,"Is pkg marked for keep"},
// Action
{"Commit", PkgDepCacheCommit, METH_VARARGS, "Commit pending changes"},
-
{}
};
diff --git a/python/generic.h b/python/generic.h
index bcdf5806..a808e28d 100644
--- a/python/generic.h
+++ b/python/generic.h
@@ -33,6 +33,17 @@
template <class T> struct CppPyObject : public PyObject
{
+ // We are only using CppPyObject and friends as dumb structs only, ie the
+ // c'tor is never called.
+ // However if T doesn't have a default c'tor C++ doesn't generate one for
+ // CppPyObject (since it can't know how it should initialize Object).
+ //
+ // This causes problems then in CppOwnedPyObject, for which C++ can't create
+ // a c'tor that calls the base class c'tor (which causes a compilation
+ // error).
+ // So basically having the c'tor here removes the need for T to have a
+ // default c'tor, which is not always desireable.
+ CppPyObject() { };
T Object;
};
diff --git a/python/pkgsrcrecords.cc b/python/pkgsrcrecords.cc
index fb66284a..8eb9e5f3 100644
--- a/python/pkgsrcrecords.cc
+++ b/python/pkgsrcrecords.cc
@@ -26,6 +26,9 @@ struct PkgSrcRecordsStruct
List.ReadMainList();
Records = new pkgSrcRecords(List);
};
+ ~PkgSrcRecordsStruct() {
+ delete Records;
+ };
};
// PkgSrcRecords Class /*{{{*/
@@ -43,7 +46,8 @@ static PyObject *PkgSrcRecordsLookup(PyObject *Self,PyObject *Args)
Struct.Last = Struct.Records->Find(Name, false);
if (Struct.Last == 0) {
Struct.Records->Restart();
- return Py_None;
+ Py_INCREF(Py_None);
+ return HandleErrors(Py_None);
}
return Py_BuildValue("i", 1);
@@ -124,6 +128,11 @@ PyTypeObject PkgSrcRecordsType =
PyObject *GetPkgSrcRecords(PyObject *Self,PyObject *Args)
{
- return CppPyObject_NEW<PkgSrcRecordsStruct>(&PkgSrcRecordsType);
+ PyObject *Owner;
+ if (PyArg_ParseTuple(Args,"O!",&PkgCacheType,&Owner) == 0)
+ return 0;
+
+ return HandleErrors(CppOwnedPyObject_NEW<PkgSrcRecordsStruct>(Owner,
+ &PkgSrcRecordsType));
}
diff --git a/python/sourcelist.cc b/python/sourcelist.cc
index 6f039244..e2343e1c 100644
--- a/python/sourcelist.cc
+++ b/python/sourcelist.cc
@@ -56,10 +56,10 @@ PyTypeObject PkgSourceListType =
PyObject_HEAD_INIT(&PyType_Type)
0, // ob_size
"pkgSourceList", // tp_name
- sizeof(CppOwnedPyObject<PkgSourceListStruct>), // tp_basicsize
+ sizeof(CppPyObject<PkgSourceListStruct>), // tp_basicsize
0, // tp_itemsize
// Methods
- CppOwnedDealloc<PkgSourceListStruct>, // tp_dealloc
+ CppDealloc<PkgSourceListStruct>, // tp_dealloc
0, // tp_print
PkgSourceListAttr, // tp_getattr
0, // tp_setattr