From c085ac239354d78c3093049a4c48a27f514c6da2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 30 Jul 2008 10:25:23 +0200 Subject: * python/cache.cc: - fix crash if Ver.PriorityType() returns NULL --- python/cache.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'python') diff --git a/python/cache.cc b/python/cache.cc index 66a2c5d9..bd280dec 100644 --- a/python/cache.cc +++ b/python/cache.cc @@ -599,7 +599,7 @@ static PyObject *VersionAttr(PyObject *Self,char *Name) else if (strcmp("Priority",Name) == 0) return Py_BuildValue("i",Ver->Priority); else if (strcmp("PriorityStr",Name) == 0) - return PyString_FromString(Ver.PriorityType()); + return Safe_FromString(Ver.PriorityType()); else if (strcmp("Downloadable", Name) == 0) return Py_BuildValue("b", Ver.Downloadable()); else if (strcmp("TranslatedDescription", Name) == 0) { -- cgit v1.2.3 From b4d0f3a1c38d916c2abda67549a454467a05fb1f Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2008 11:42:55 +0200 Subject: fix GetCandidateVer() reporting incorrect versions after SetCandidateVer() was used. Thanks to Julian Andres Klode for the test-case (LP: #237372) --- debian/changelog | 3 +++ po/python-apt.pot | 2 +- python/depcache.cc | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index 86e5b0c9..1afcb16e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,9 @@ python-apt (0.7.7.2) UNRELEASED; urgency=low * python/cache.cc: - fix crash if Ver.PriorityType() returns NULL + - fix GetCandidateVer() reporting incorrect versions after + SetCandidateVer() was used. Thanks to Julian Andres Klode for + the test-case (LP: #237372) * apt/cache.py: - support "in" in apt.Cache() (LP: #251587) diff --git a/po/python-apt.pot b/po/python-apt.pot index 9dc6e202..20905fdf 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-07-30 10:24+0200\n" +"POT-Creation-Date: 2008-07-31 11:40+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/depcache.cc b/python/depcache.cc index 5664a6d8..2446dc71 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -197,7 +197,7 @@ static PyObject *PkgDepCacheSetCandidateVer(PyObject *Self,PyObject *Args) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); - pkgCache::VerIterator I = GetCpp(VersionObj); + pkgCache::VerIterator &I = GetCpp(VersionObj); if(I.end()) { return HandleErrors(Py_BuildValue("b",false)); } @@ -215,7 +215,9 @@ static PyObject *PkgDepCacheGetCandidateVer(PyObject *Self,PyObject *Args) return 0; pkgCache::PkgIterator &Pkg = GetCpp(PackageObj); - pkgCache::VerIterator I = depcache->GetCandidateVer(Pkg); + pkgDepCache::StateCache & State = (*depcache)[Pkg]; + pkgCache::VerIterator I = State.CandidateVerIter(*depcache); + if(I.end()) { Py_INCREF(Py_None); return Py_None; -- cgit v1.2.3 From 19fdcab7acc03ceb6aaf57f7ccdd754a41aa7b6e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2008 12:01:43 +0200 Subject: * python/apt_instmodule.cc: - do not change working dir in debExtractArchive() (LP: #184093) --- debian/changelog | 2 ++ po/python-apt.pot | 2 +- python/apt_instmodule.cc | 13 ++++++++++--- tests/test_extract_archive.py | 10 ++++++++++ 4 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 tests/test_extract_archive.py (limited to 'python') diff --git a/debian/changelog b/debian/changelog index 1afcb16e..8cac6ae2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -5,6 +5,8 @@ python-apt (0.7.7.2) UNRELEASED; urgency=low - fix GetCandidateVer() reporting incorrect versions after SetCandidateVer() was used. Thanks to Julian Andres Klode for the test-case (LP: #237372) + * python/apt_instmodule.cc: + - do not change working dir in debExtractArchive() (LP: #184093) * apt/cache.py: - support "in" in apt.Cache() (LP: #251587) diff --git a/po/python-apt.pot b/po/python-apt.pot index 20905fdf..7e731689 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-07-31 11:40+0200\n" +"POT-Creation-Date: 2008-07-31 12:00+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 43d5e7f7..6e6c89dd 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -74,6 +74,7 @@ static char *doc_debExtractArchive = static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { char *Rootdir = NULL; + char cwd[512]; PyObject *File; if (PyArg_ParseTuple(Args,"O!|s",&PyFile_Type,&File,&Rootdir) == 0) return 0; @@ -83,21 +84,27 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) { if(Rootdir != NULL) { + getcwd(cwd, sizeof(cwd)); chdir(Rootdir); } // Open the file and associate the .deb FileFd Fd(fileno(PyFile_AsFile(File)),false); debDebFile Deb(Fd); - if (_error->PendingError() == true) - return HandleErrors(); + if (_error->PendingError() == true) { + if (cwd != NULL) + chdir (cwd); + return HandleErrors(Py_BuildValue("b",false)); + } // extracts relative to the current dir pkgDirStream Extract; res = Deb.ExtractArchive(Extract); + if (cwd != NULL) + chdir (cwd); if (res == false) - return HandleErrors(); + return HandleErrors(Py_BuildValue("b",res)); } return HandleErrors(Py_BuildValue("b",res)); } diff --git a/tests/test_extract_archive.py b/tests/test_extract_archive.py new file mode 100644 index 00000000..ce202b06 --- /dev/null +++ b/tests/test_extract_archive.py @@ -0,0 +1,10 @@ +#!/usr/bin/python + +import apt +import apt_inst +import os +import sys + +print os.getcwd() +apt_inst.debExtractArchive(open(sys.argv[1]), "/tmp/") +print os.getcwd() -- cgit v1.2.3 From bb53ee921fc357decaa6b1f8660f9d6ce621eafb Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 31 Jul 2008 12:18:46 +0200 Subject: * python/apt_instmodule.cc: - fix bug in Rootdir cwd code --- python/apt_instmodule.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'python') diff --git a/python/apt_instmodule.cc b/python/apt_instmodule.cc index 6e6c89dd..ea703b21 100644 --- a/python/apt_instmodule.cc +++ b/python/apt_instmodule.cc @@ -92,7 +92,7 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) FileFd Fd(fileno(PyFile_AsFile(File)),false); debDebFile Deb(Fd); if (_error->PendingError() == true) { - if (cwd != NULL) + if (Rootdir != NULL) chdir (cwd); return HandleErrors(Py_BuildValue("b",false)); } @@ -101,7 +101,7 @@ static PyObject *debExtractArchive(PyObject *Self,PyObject *Args) pkgDirStream Extract; res = Deb.ExtractArchive(Extract); - if (cwd != NULL) + if (Rootdir != NULL) chdir (cwd); if (res == false) return HandleErrors(Py_BuildValue("b",res)); -- cgit v1.2.3 From 34503feab88a8aa72ef511f86375933a4d8707ef Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 15 Aug 2008 10:02:54 +0200 Subject: * python/progress.cc: - when pulse() does not return a boolean assume "true" (thanks to Martin Pitt for telling me about the problem) --- debian/changelog | 3 +++ po/python-apt.pot | 2 +- python/progress.cc | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index 8cac6ae2..6a8b7f7e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,9 @@ python-apt (0.7.7.2) UNRELEASED; urgency=low - do not change working dir in debExtractArchive() (LP: #184093) * apt/cache.py: - support "in" in apt.Cache() (LP: #251587) + * python/progress.cc: + - when pulse() does not return a boolean assume "true" + (thanks to Martin Pitt for telling me about the problem) -- Michael Vogt Wed, 30 Jul 2008 10:24:30 +0200 diff --git a/po/python-apt.pot b/po/python-apt.pot index 7e731689..3d513b7b 100644 --- a/po/python-apt.pot +++ b/po/python-apt.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-07-31 12:00+0200\n" +"POT-Creation-Date: 2008-08-15 09:59+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" diff --git a/python/progress.cc b/python/progress.cc index 793265db..99ad0a25 100644 --- a/python/progress.cc +++ b/python/progress.cc @@ -185,8 +185,10 @@ bool PyFetchProgress::Pulse(pkgAcquire * Owner) bool res = true; if(!PyArg_Parse(result, "b", &res)) { - // mvo: this is harmless, we shouldn't print anything here - //std::cerr << "result could not be parsed" << std::endl; + // most of the time the user who subclasses the pulse() + // method forgot to add a return {True,False} so we just + // assume he wants a True + return true; } // fetching can be canceld by returning false -- cgit v1.2.3 From 4474bb62bda8087f63a9e35edb2f6fcaa1bd96d1 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Thu, 18 Sep 2008 14:48:12 +0200 Subject: add "SelState{Unknown,Install,Hold,DeInstall,Purge}" constant --- debian/changelog | 2 +- python/apt_pkgmodule.cc | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'python') diff --git a/debian/changelog b/debian/changelog index e9d5710c..dc9c2501 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,4 +1,4 @@ -python-apt (0.7.7.2) UNRELEASED; urgency=low +python-apt (0.7.8) UNRELEASED; urgency=low * python/cache.cc: - fix crash if Ver.PriorityType() returns NULL diff --git a/python/apt_pkgmodule.cc b/python/apt_pkgmodule.cc index fd7a83cd..fae85f00 100644 --- a/python/apt_pkgmodule.cc +++ b/python/apt_pkgmodule.cc @@ -517,6 +517,12 @@ extern "C" void initapt_pkg() AddInt(Dict,"CurStateConfigFiles",pkgCache::State::ConfigFiles); AddInt(Dict,"CurStateInstalled",pkgCache::State::Installed); + AddInt(Dict,"SelStateUnknown",pkgCache::State::Unknown); + AddInt(Dict,"SelStateInstall",pkgCache::State::Install); + AddInt(Dict,"SelStateHold",pkgCache::State::Hold); + AddInt(Dict,"SelStateDeInstall",pkgCache::State::DeInstall); + AddInt(Dict,"SelStatePurge",pkgCache::State::Purge); + AddInt(Dict,"InstStateOk",pkgCache::State::Ok); AddInt(Dict,"InstStateReInstReq",pkgCache::State::ReInstReq); AddInt(Dict,"InstStateHold",pkgCache::State::Hold); -- cgit v1.2.3