From d65882227dd3201c03c87922391d1ad8d21ee84e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 12 Sep 2006 11:32:37 +0200 Subject: * python/pkgmanager.cc: - fix typo --- python/pkgmanager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python') 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"}, {} -- cgit v1.2.3 From 8df7cb6c729a5451f231f2cd3e82fc495eaea289 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 12 Sep 2006 15:35:55 +0200 Subject: * fix missing docstring --- debian/changelog | 4 ++++ python/apt_pkgmodule.cc | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index 02ec00a1..7029a040 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,10 @@ python-apt (0.6.20) unstable; urgency=low * apt/progress.py: - use os._exit() in the child (lp: #53298) - use select() when checking for statusfd (lp: #53282) + * acknoledge NMU (closes: #378048, #373512) + * python/apt_pkgmodule.cc: + - fix missing docstring (closes: #368907), + Thanks to Josh Triplett -- 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"}, {} }; -- cgit v1.2.3 From 0d7ffbdfcecfde690648da1ff9342d3bd736e71f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 18 Sep 2006 18:40:30 +0200 Subject: * fix api changes for python2.5 --- debian/changelog | 1 + python/cache.cc | 8 ++++---- python/tag.cc | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index 7029a040..21cbd6a8 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ python-apt (0.6.20) unstable; urgency=low * python/apt_pkgmodule.cc: - fix missing docstring (closes: #368907), Thanks to Josh Triplett + * make it build against python2.5 -- 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(Self).Iter.Cache()->HeaderP->PackageCount; } -static PyObject *PkgListItem(PyObject *iSelf,int Index) +static PyObject *PkgListItem(PyObject *iSelf,Py_ssize_t Index) { PkgListStruct &Self = GetCpp(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(Self).Len; } -static PyObject *RDepListItem(PyObject *iSelf,int Index) +static PyObject *RDepListItem(PyObject *iSelf,Py_ssize_t Index) { RDepListStruct &Self = GetCpp(iSelf); if (Index < 0 || (unsigned)Index >= Self.Len) diff --git a/python/tag.cc b/python/tag.cc index 41db059c..883a8eab 100644 --- a/python/tag.cc +++ b/python/tag.cc @@ -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(Self); return Sec.Count(); -- cgit v1.2.3 From ddfb5f9abcc398843e48885bbc8b3e4439c14e7b Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 18 Sep 2006 19:26:55 +0200 Subject: * python/generic.h: - deal with the api change and stay backward compatible with 2.4 --- python/generic.h | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'python') diff --git a/python/generic.h b/python/generic.h index a808e28d..b47ed1a2 100644 --- a/python/generic.h +++ b/python/generic.h @@ -31,6 +31,10 @@ #include #include +#if PYTHON_API_VERSION < 1013 +typedef int Py_ssize_t; +#endif + template struct CppPyObject : public PyObject { // We are only using CppPyObject and friends as dumb structs only, ie the -- cgit v1.2.3 From c00b2271e6295c248c18d1bd62e14df372004e85 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Mon, 2 Oct 2006 18:20:49 +0200 Subject: * progress.cc: - fix memleak in progress.cc * tests/memleak.py: - uncomment the mem-leak code * doc/examples/sources.py: - improved the example --- debian/changelog | 4 +++- doc/examples/sources.py | 2 +- python/progress.cc | 10 +++++++--- tests/memleak.py | 14 +++++++++----- 4 files changed, 20 insertions(+), 10 deletions(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index 21cbd6a8..1979f75d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,8 +12,10 @@ python-apt (0.6.20) unstable; urgency=low - fix missing docstring (closes: #368907), Thanks to Josh Triplett * make it build against python2.5 + * python/progress.cc: + - fix memleak (lp: #43096) - -- + -- Michael Vogt Mon, 2 Oct 2006 17:29:49 +0200 python-apt (0.6.19) unstable; urgency=low diff --git a/doc/examples/sources.py b/doc/examples/sources.py index c12c6f15..b48c0ba5 100644 --- a/doc/examples/sources.py +++ b/doc/examples/sources.py @@ -12,4 +12,4 @@ sources.Restart() while sources.Lookup('hello'): print sources.Package, sources.Version, sources.Maintainer, sources.Section, `sources.Binaries` print sources.Files - print sources.Index.ArchiveURI("") + print sources.Index.ArchiveURI(sources.Files[0][2]) 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/tests/memleak.py b/tests/memleak.py index 3e59cbb7..b5d05afc 100755 --- a/tests/memleak.py +++ b/tests/memleak.py @@ -10,11 +10,15 @@ import sys cache = apt.Cache() # memleak -#for i in range(100): -# cache.open(None) -# print cache["apt"].name -# time.sleep(1) -# gc.collect() +for i in range(100): + cache.open(None) + print cache["apt"].name + time.sleep(1) + gc.collect() + f = open("%s" % i,"w") + for obj in gc.get_objects(): + f.write("%s\n" % str(obj)) + f.close() # memleak #for i in range(100): -- cgit v1.2.3 From 722f0d8b1a276f2f069fc090db2365ae2659fac9 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 4 Oct 2006 16:39:18 +0200 Subject: * python/generic.h: - use PyObject_DEL() instead of PyMem_DEL() --- debian/changelog | 9 +++++++++ python/generic.h | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index 1979f75d..3ab21a51 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,12 @@ +python-apt (0.6.21) unstable; urgency=low + + * python/generic.h: + - fix incorrect use of PyMem_DEL(), use pyObject_DEL() + instead. This fixes a nasty segfault with python2.5 + (lp: 63226) + + -- + python-apt (0.6.20) unstable; urgency=low * python/pkgmanager.cc: diff --git a/python/generic.h b/python/generic.h index b47ed1a2..a1b662bb 100644 --- a/python/generic.h +++ b/python/generic.h @@ -113,7 +113,7 @@ template void CppDealloc(PyObject *Obj) { GetCpp(Obj).~T(); - PyMem_DEL(Obj); + PyObject_DEL(Obj); } template @@ -123,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) -- cgit v1.2.3 From 9e5bfd3bc00a88094e6d16dcce6f50a0f51a5ee6 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 4 Oct 2006 16:54:00 +0200 Subject: * python/tag.cc: - fix another PyMem_DEL() -> PyObject_DEL() error --- python/tag.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python') diff --git a/python/tag.cc b/python/tag.cc index 883a8eab..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); } /*}}}*/ -- cgit v1.2.3 From 053d66916010f0f4e2b234c6bbd93e0afe79631e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 4 Oct 2006 17:00:42 +0200 Subject: * python/configuration.cc: - and the final(!?!) incorrect PyMem_{DEL,Free} usage --- python/configuration.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python') 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), // 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 -- cgit v1.2.3 From 3c393390f10b5ecfb3891fb89f199e2610d9246e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 19 Dec 2006 11:46:28 +0100 Subject: * python/pkgrecords.cc: - export SHA1Sum() as well * debian/changelog: - updated --- debian/changelog | 9 ++++++--- python/pkgrecords.cc | 2 ++ 2 files changed, 8 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index 9451428c..6b52ff44 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,13 +1,16 @@ -python-apt (0.6.21) unstable; urgency=low +python-apt (0.6.21) UNRELEASED; urgency=low * python/generic.h: - fix incorrect use of PyMem_DEL(), use pyObject_DEL() instead. This fixes a nasty segfault with python2.5 (lp: 63226) + * python/pkgrecords.cc: + - export SHA1Hash() as well * debian/rules: Remove dh_python call. - * protect against not-parsable strings send from dpkg (lp: 68553) + * apt/progress.cc: + - protect against not-parsable strings send from dpkg (lp: 68553) - -- + -- Michael Vogt Tue, 19 Dec 2006 11:34:59 +0100 python-apt (0.6.20) unstable; urgency=low 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) -- cgit v1.2.3 From fb94875bd4e108c6d22e05d5312de7ed9f86b057 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 22 Feb 2007 15:31:00 +0100 Subject: * python/string.cc: - SizeToString supports PyLong too --- debian/changelog | 2 ++ python/string.cc | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index da487377..7833dc00 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,8 @@ python-apt (0.6.21) unstable; urgency=low * apt/cdrom.py: - better cdrom handling support + * python/string.cc: + - SizeToString supports PyLong too -- 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; -- cgit v1.2.3 From cccfb88edd8dd82348ff89f96a0b26ac815b483c Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 25 Apr 2007 16:17:01 +0200 Subject: * python/apt_pkgmodule.cc: - added pkgCache::State::PkgCurrentState enums --- debian/changelog | 7 +++++++ python/apt_pkgmodule.cc | 6 ++++++ 2 files changed, 13 insertions(+) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index eabbc931..75725676 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +python-apt (0.6.22) unstable; urgency=low + + * python/apt_pkgmodule.cc: + - added pkgCache::State::PkgCurrentState enums + + -- + python-apt (0.6.21) unstable; urgency=low * apt/cdrom.py: diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index 24d876af..627eaced 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -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); } /*}}}*/ -- cgit v1.2.3