summaryrefslogtreecommitdiff
path: root/python
diff options
context:
space:
mode:
authorMichael Vogt <egon@bottom>2007-05-02 18:43:13 +0200
committerMichael Vogt <egon@bottom>2007-05-02 18:43:13 +0200
commit500e805d3fa7faee957e67410f525435224f1e21 (patch)
treefad6c63e9aa28d7df2effe7d378923e05cf2db10 /python
parenta231ca12f5fbb6adb55142973eb4d7a284763ace (diff)
parentcccfb88edd8dd82348ff89f96a0b26ac815b483c (diff)
downloadpython-apt-500e805d3fa7faee957e67410f525435224f1e21.tar.gz
* merged from python-apt--mvo
Diffstat (limited to 'python')
-rw-r--r--python/apt_pkgmodule.cc8
-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/string.cc6
-rw-r--r--python/tag.cc4
9 files changed, 34 insertions, 16 deletions
diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc
index b1c5c2a5..627eaced 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"},
{}
};
@@ -502,6 +502,12 @@ extern "C" void initapt_pkg()
AddInt(Dict,"PriOptional",pkgCache::State::Optional);
AddInt(Dict,"PriExtra",pkgCache::State::Extra);
+ AddInt(Dict,"CurStateNotInstalled",pkgCache::State::NotInstalled);
+ AddInt(Dict,"CurStateUnPacked",pkgCache::State::UnPacked);
+ AddInt(Dict,"CurStateHalfConfigured",pkgCache::State::HalfConfigured);
+ AddInt(Dict,"CurStateHalfInstalled",pkgCache::State::HalfInstalled);
+ AddInt(Dict,"CurStateConfigFiles",pkgCache::State::ConfigFiles);
+ AddInt(Dict,"CurStateInstalled",pkgCache::State::Installed);
}
/*}}}*/
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/string.cc b/python/string.cc
index 16adc8cd..d0926da5 100644
--- a/python/string.cc
+++ b/python/string.cc
@@ -53,9 +53,11 @@ PyObject *StrSizeToStr(PyObject *Self,PyObject *Args)
if (PyArg_ParseTuple(Args,"O",&Obj) == 0)
return 0;
if (PyInt_Check(Obj))
- return CppPyString(SizeToStr(PyInt_AS_LONG(Obj)));
+ return CppPyString(SizeToStr(PyInt_AsLong(Obj)));
+ if (PyLong_Check(Obj))
+ return CppPyString(SizeToStr(PyLong_AsLong(Obj)));
if (PyFloat_Check(Obj))
- return CppPyString(SizeToStr(PyFloat_AS_DOUBLE(Obj)));
+ return CppPyString(SizeToStr(PyFloat_AsDouble(Obj)));
PyErr_SetString(PyExc_TypeError,"Only understand integers and floats");
return 0;
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();