summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2006-12-19 11:50:52 +0100
committerMichael Vogt <egon@bottom>2006-12-19 11:50:52 +0100
commit75da7640381be141209986156eba32825019add8 (patch)
tree5aa439eeeb55331ca9e8d3245b0c387d8c58ca10 /python
parenta38c71a5197429ccb1703d9b3c2d943be6017f7d (diff)
parent3c393390f10b5ecfb3891fb89f199e2610d9246e (diff)
downloadpython-apt-75da7640381be141209986156eba32825019add8.tar.gz
* merged from mainline
Diffstat (limited to 'python')
-rw-r--r--python/apt_pkgmodule.cc2
-rw-r--r--python/cache.cc8
-rw-r--r--python/configuration.cc2
-rw-r--r--python/generic.h8
-rw-r--r--python/pkgmanager.cc2
-rw-r--r--python/pkgrecords.cc2
-rw-r--r--python/progress.cc10
-rw-r--r--python/tag.cc4
8 files changed, 24 insertions, 14 deletions
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index b1c5c2a5..24d876af 100644
--- a/python/apt_pkgmodule.cc
+++ b/python/apt_pkgmodule.cc
@@ -440,7 +440,7 @@ static PyMethodDef methods[] =
{"GetPkgAcqFile",(PyCFunction)GetPkgAcqFile,METH_KEYWORDS|METH_VARARGS,"GetPkgAcquireFile() -> pkgAcquireFile"},
// PkgManager
- {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager() -> PackageManager"},
+ {"GetPackageManager",GetPkgManager,METH_VARARGS,"GetPackageManager(DepCache) -> PackageManager"},
{}
};
diff --git a/python/cache.cc b/python/cache.cc
index 174423c2..b6278de0 100644
--- a/python/cache.cc
+++ b/python/cache.cc
@@ -287,12 +287,12 @@ PyTypeObject PkgCacheFileType =
/*}}}*/
// Package List Class /*{{{*/
// ---------------------------------------------------------------------
-static int PkgListLen(PyObject *Self)
+static Py_ssize_t PkgListLen(PyObject *Self)
{
return GetCpp<PkgListStruct>(Self).Iter.Cache()->HeaderP->PackageCount;
}
-static PyObject *PkgListItem(PyObject *iSelf,int Index)
+static PyObject *PkgListItem(PyObject *iSelf,Py_ssize_t Index)
{
PkgListStruct &Self = GetCpp<PkgListStruct>(iSelf);
if (Index < 0 || (unsigned)Index >= Self.Iter.Cache()->HeaderP->PackageCount)
@@ -815,12 +815,12 @@ PyTypeObject DependencyType =
/*}}}*/
// Reverse Dependency List Class /*{{{*/
// ---------------------------------------------------------------------
-static int RDepListLen(PyObject *Self)
+static Py_ssize_t RDepListLen(PyObject *Self)
{
return GetCpp<RDepListStruct>(Self).Len;
}
-static PyObject *RDepListItem(PyObject *iSelf,int Index)
+static PyObject *RDepListItem(PyObject *iSelf,Py_ssize_t Index)
{
RDepListStruct &Self = GetCpp<RDepListStruct>(iSelf);
if (Index < 0 || (unsigned)Index >= Self.Len)
diff --git a/python/configuration.cc b/python/configuration.cc
index 6cf33581..55eac1bf 100644
--- a/python/configuration.cc
+++ b/python/configuration.cc
@@ -490,7 +490,7 @@ PyTypeObject ConfigurationPtrType =
sizeof(CppPyObject<Configuration *>), // tp_basicsize
0, // tp_itemsize
// Methods
- (destructor)PyMem_Free, // tp_dealloc
+ (destructor)PyObject_Free, // tp_dealloc
0, // tp_print
CnfGetAttr, // tp_getattr
0, // tp_setattr
diff --git a/python/generic.h b/python/generic.h
index a808e28d..a1b662bb 100644
--- a/python/generic.h
+++ b/python/generic.h
@@ -31,6 +31,10 @@
#include <string>
#include <new>
+#if PYTHON_API_VERSION < 1013
+typedef int Py_ssize_t;
+#endif
+
template <class T> struct CppPyObject : public PyObject
{
// We are only using CppPyObject and friends as dumb structs only, ie the
@@ -109,7 +113,7 @@ template <class T>
void CppDealloc(PyObject *Obj)
{
GetCpp<T>(Obj).~T();
- PyMem_DEL(Obj);
+ PyObject_DEL(Obj);
}
template <class T>
@@ -119,7 +123,7 @@ void CppOwnedDealloc(PyObject *iObj)
Obj->Object.~T();
if (Obj->Owner != 0)
Py_DECREF(Obj->Owner);
- PyMem_DEL(Obj);
+ PyObject_DEL(Obj);
}
inline PyObject *CppPyString(std::string Str)
diff --git a/python/pkgmanager.cc b/python/pkgmanager.cc
index bcd4c45b..9670f238 100644
--- a/python/pkgmanager.cc
+++ b/python/pkgmanager.cc
@@ -68,7 +68,7 @@ static PyObject *PkgManagerFixMissing(PyObject *Self,PyObject *Args)
static PyMethodDef PkgManagerMethods[] =
{
- {"GetArchives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archvies into the fetcher"},
+ {"GetArchives",PkgManagerGetArchives,METH_VARARGS,"Load the selected archives into the fetcher"},
{"DoInstall",PkgManagerDoInstall,METH_VARARGS,"Do the actual install"},
{"FixMissing",PkgManagerFixMissing,METH_VARARGS,"Fix the install if a pkg couldn't be downloaded"},
{}
diff --git a/python/pkgrecords.cc b/python/pkgrecords.cc
index ec78f554..4a5556f2 100644
--- a/python/pkgrecords.cc
+++ b/python/pkgrecords.cc
@@ -63,6 +63,8 @@ static PyObject *PkgRecordsAttr(PyObject *Self,char *Name)
return CppPyString(Struct.Last->FileName());
else if (strcmp("MD5Hash",Name) == 0)
return CppPyString(Struct.Last->MD5Hash());
+ else if (strcmp("SHA1Hash",Name) == 0)
+ return CppPyString(Struct.Last->SHA1Hash());
else if (strcmp("SourcePkg",Name) == 0)
return CppPyString(Struct.Last->SourcePkg());
else if (strcmp("Maintainer",Name) == 0)
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/python/tag.cc b/python/tag.cc
index 41db059c..d0d862c9 100644
--- a/python/tag.cc
+++ b/python/tag.cc
@@ -68,7 +68,7 @@ void TagFileFree(PyObject *Obj)
Self->Object.~pkgTagFile();
Self->Fd.~FileFd();
Py_DECREF(Self->File);
- PyMem_DEL(Obj);
+ PyObject_DEL(Obj);
}
/*}}}*/
@@ -132,7 +132,7 @@ static PyObject *TagSecMap(PyObject *Self,PyObject *Arg)
}
// len() operation
-static int TagSecLength(PyObject *Self)
+static Py_ssize_t TagSecLength(PyObject *Self)
{
pkgTagSection &Sec = GetCpp<pkgTagSection>(Self);
return Sec.Count();