diff options
| author | Michael Vogt <egon@bottom> | 2006-12-19 11:50:52 +0100 |
|---|---|---|
| committer | Michael Vogt <egon@bottom> | 2006-12-19 11:50:52 +0100 |
| commit | 75da7640381be141209986156eba32825019add8 (patch) | |
| tree | 5aa439eeeb55331ca9e8d3245b0c387d8c58ca10 | |
| parent | a38c71a5197429ccb1703d9b3c2d943be6017f7d (diff) | |
| parent | 3c393390f10b5ecfb3891fb89f199e2610d9246e (diff) | |
| download | python-apt-75da7640381be141209986156eba32825019add8.tar.gz | |
* merged from mainline
| -rw-r--r-- | apt/progress.py | 25 | ||||
| -rw-r--r-- | debian/changelog | 33 | ||||
| -rw-r--r-- | debian/control | 2 | ||||
| -rwxr-xr-x | debian/rules | 3 | ||||
| -rw-r--r-- | doc/examples/inst.py | 5 | ||||
| -rw-r--r-- | doc/examples/sources.py | 2 | ||||
| -rw-r--r-- | python/apt_pkgmodule.cc | 2 | ||||
| -rw-r--r-- | python/cache.cc | 8 | ||||
| -rw-r--r-- | python/configuration.cc | 2 | ||||
| -rw-r--r-- | python/generic.h | 8 | ||||
| -rw-r--r-- | python/pkgmanager.cc | 2 | ||||
| -rw-r--r-- | python/pkgrecords.cc | 2 | ||||
| -rw-r--r-- | python/progress.cc | 10 | ||||
| -rw-r--r-- | python/tag.cc | 4 | ||||
| -rwxr-xr-x | tests/memleak.py | 14 |
15 files changed, 89 insertions, 33 deletions
diff --git a/apt/progress.py b/apt/progress.py index 4119067c..5169adf7 100644 --- a/apt/progress.py +++ b/apt/progress.py @@ -19,7 +19,14 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA -import sys, apt_pkg, os, fcntl, string, re +import sys +import os +import re +import fcntl +import string +from errno import * +import select +import apt_pkg class OpProgress(object): """ Abstract class to implement reporting on cache opening @@ -139,6 +146,7 @@ class InstallProgress(DumbInstallProgress): """ def __init__(self): DumbInstallProgress.__init__(self) + self.selectTimeout = 0.1 (read, write) = os.pipe() self.writefd=write self.statusfd = os.fdopen(read, "r") @@ -162,12 +170,17 @@ class InstallProgress(DumbInstallProgress): self.read += os.read(self.statusfd.fileno(),1) except OSError, (errno,errstr): # resource temporarly unavailable is ignored - if errno != 11: + if errno != EAGAIN and errnor != EWOULDBLOCK: print errstr if self.read.endswith("\n"): s = self.read #print s - (status, pkg, percent, status_str) = string.split(s, ":") + try: + (status, pkg, percent, status_str) = string.split(s, ":",3) + except ValueError, e: + # silently ignore lines that can't be parsed + self.read = "" + return #print "percent: %s %s" % (pkg, float(percent)/100.0) if status == "pmerror": self.error(pkg,status_str) @@ -184,22 +197,22 @@ class InstallProgress(DumbInstallProgress): self.percent = float(percent) self.status = string.strip(status_str) self.read = "" - def fork(self): return os.fork() def waitChild(self): while True: + select.select([self.statusfd],[],[], self.selectTimeout) + self.updateInterface() (pid, res) = os.waitpid(self.child_pid,os.WNOHANG) if pid == self.child_pid: break - self.updateInterface() return os.WEXITSTATUS(res) def run(self, pm): pid = self.fork() if pid == 0: # child res = pm.DoInstall(self.writefd) - sys.exit(res) + os._exit(res) self.child_pid = pid res = self.waitChild() return res diff --git a/debian/changelog b/debian/changelog index 3e93cad9..fd149824 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,36 @@ +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. + * apt/progress.cc: + - protect against not-parsable strings send from dpkg (lp: 68553) + + -- Michael Vogt <michael.vogt@ubuntu.com> Tue, 19 Dec 2006 11:34:59 +0100 + +python-apt (0.6.20) unstable; urgency=low + + * python/pkgmanager.cc: + - fix typo (closes: #382853) + * debian/control: + - tightend dependency (closes: #383478) + * 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 + * make it build against python2.5 + * python/progress.cc: + - fix memleak (lp: #43096) + + -- Michael Vogt <michael.vogt@ubuntu.com> Mon, 2 Oct 2006 17:29:49 +0200 + python-apt (0.6.19) unstable; urgency=low [ Michael Vogt ] diff --git a/debian/control b/debian/control index 5fa1bc83..e2f97b78 100644 --- a/debian/control +++ b/debian/control @@ -5,7 +5,7 @@ Maintainer: APT Development Team <deity@lists.debian.org> Uploaders: Matt Zimmerman <mdz@debian.org>, Michael Vogt <mvo@debian.org> Standards-Version: 3.6.2.0 XS-Python-Version: all -Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.6.40), apt-utils, python-all-dev, python-central +Build-Depends: debhelper (>= 5.0.37.1), libapt-pkg-dev (>= 0.6.45), apt-utils, python-all-dev, python-central Package: python-apt Architecture: any diff --git a/debian/rules b/debian/rules index ee159b89..7299f554 100755 --- a/debian/rules +++ b/debian/rules @@ -49,12 +49,11 @@ binary-arch: build for PY in $(PYTHON); do \ /usr/bin/$$PY setup.py install --prefix=`pwd`/debian/python-apt/usr; \ done - + dh_installdocs dh_installchangelogs dh_installexamples dh_pycentral - dh_python dh_strip dh_compress dh_fixperms diff --git a/doc/examples/inst.py b/doc/examples/inst.py index 0e91c28f..ff9d452c 100644 --- a/doc/examples/inst.py +++ b/doc/examples/inst.py @@ -29,10 +29,7 @@ cache = apt.Cache(apt.progress.OpTextProgress()) fprogress = apt.progress.TextFetchProgress() iprogress = TextInstallProgress() -pkg = cache["test-package"] -pkg.markUpgrade() -cache.commit(fprogress,iprogress) -sys.exit(1) +pkg = cache["3dchess"] # install or remove, the importend thing is to keep us busy :) if pkg.isInstalled: 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/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(); 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): |
