From f7d22dc2e7964ce33415e53a81dfc62439111491 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Wed, 24 Nov 2010 10:46:40 +0100 Subject: * tests/test_apt_cache.py: - fix tests to work if apt compressed indexes are enabled --- debian/changelog | 2 ++ tests/test_apt_cache.py | 17 +++++++---------- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/debian/changelog b/debian/changelog index b78a58af..a198781b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -33,6 +33,8 @@ python-apt (0.7.98) unstable; urgency=low - do use PyString_FromFormat(), in python versions below 2.7 it does not support long long (%llu), use strprintf() from libapt instead + * tests/test_apt_cache.py: + - fix tests to work if apt compressed indexes are enabled [ Kiwinote ] * apt/debfile: diff --git a/tests/test_apt_cache.py b/tests/test_apt_cache.py index efa73a4f..0b33a2e3 100644 --- a/tests/test_apt_cache.py +++ b/tests/test_apt_cache.py @@ -18,6 +18,7 @@ sys.path.insert(0, get_library_dir()) import apt import apt_pkg import shutil +import glob class TestAptCache(unittest.TestCase): """ test the apt cache """ @@ -139,12 +140,11 @@ class TestAptCache(unittest.TestCase): cache = apt.Cache() cache.update(sources_list=sources_list) # verify we just got the excpected package file - needle_packages = [f for f in os.listdir(lists_dir) - if f.endswith("tests_data_test-repo_Packages")] + needle_packages = glob.glob( + lists_dir+"/*tests_data_test-repo_Packages*") self.assertEqual(len(needle_packages), 1) # verify that we *only* got the Packages file from a single source - all_packages = [f for f in os.listdir(lists_dir) - if f.endswith("_Packages")] + all_packages = glob.glob(lists_dir+"/*_Packages*") self.assertEqual(needle_packages, all_packages) # verify that the listcleaner was not run and the marker file is # still there @@ -153,18 +153,15 @@ class TestAptCache(unittest.TestCase): # now run update again (without the "normal" sources.list that # contains test-repo2 and verify that we got the normal sources.list cache.update() - needle_packages = [f for f in os.listdir(lists_dir) - if f.endswith("tests_data_test-repo2_Packages")] + needle_packages = glob.glob(lists_dir+"/*tests_data_test-repo2_Packages*") self.assertEqual(len(needle_packages), 1) - all_packages = [f for f in os.listdir(lists_dir) - if f.endswith("_Packages")] + all_packages = glob.glob(lists_dir+"/*_Packages*") self.assertEqual(needle_packages, all_packages) # and another update with a single source only cache = apt.Cache() cache.update(sources_list=sources_list) - all_packages = [f for f in os.listdir(lists_dir) - if f.endswith("_Packages")] + all_packages = glob.glob(lists_dir+"/*_Packages*") self.assertEqual(len(all_packages), 2) if __name__ == "__main__": -- cgit v1.2.3 From d3897306b07fab8490b32e8822685b54959be3e5 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 7 Dec 2010 13:42:38 +0100 Subject: * python/generic.h: - set Object to NULL in CppDeallocPtr * python/depcache.cc: - don't run "actiongroup.release()" if the object was already deallocated --- debian/changelog | 10 ++++++++++ python/depcache.cc | 3 ++- python/generic.h | 4 +++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/debian/changelog b/debian/changelog index 8c8613d1..1d59b94f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,13 @@ +python-apt (0.7.100.1) UNRELEASED; urgency=low + + * python/generic.h: + - set Object to NULL in CppDeallocPtr + * python/depcache.cc: + - don't run "actiongroup.release()" if the object was already + deallocated + + -- Michael Vogt Tue, 07 Dec 2010 13:41:07 +0100 + python-apt (0.7.100) unstable; urgency=low * Final 0.7.100 release; targeted at Squeeze. diff --git a/python/depcache.cc b/python/depcache.cc index b7294644..014ad7ae 100644 --- a/python/depcache.cc +++ b/python/depcache.cc @@ -997,7 +997,8 @@ static const char *actiongroup__exit__doc = "Same as release(), but for use as a context manager."; static PyObject *PkgActionGroupExit(PyObject *Self,PyObject *Args) { pkgDepCache::ActionGroup *ag = GetCpp(Self); - ag->release(); + if (ag != NULL) + ag->release(); Py_RETURN_FALSE; } diff --git a/python/generic.h b/python/generic.h index 31c1bc2d..7abf7e7a 100644 --- a/python/generic.h +++ b/python/generic.h @@ -202,8 +202,10 @@ void CppDeallocPtr(PyObject *iObj) std::cerr << "=== DEALLOCATING " << iObj->ob_type->tp_name << "*+ ===\n"; #endif CppPyObject *Obj = (CppPyObject *)iObj; - if (!((CppPyObject*)Obj)->NoDelete) + if (!((CppPyObject*)Obj)->NoDelete) { delete Obj->Object; + Obj->Object = NULL; + } CppClear(iObj); iObj->ob_type->tp_free(iObj); } -- cgit v1.2.3 From 6a05a8302c405c4c8d1b59f6be8c2d0974c6ce1e Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Tue, 7 Dec 2010 14:35:48 +0100 Subject: tests/test_all.py: add workaround for py3.2 --- tests/test_all.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/test_all.py b/tests/test_all.py index d6370747..091581f8 100644 --- a/tests/test_all.py +++ b/tests/test_all.py @@ -9,6 +9,14 @@ import os import unittest import sys +# workaround for py3.2 that apparently does not have this anymore +# it has "abiflags" +if not hasattr(sys, "pydebug"): + if sys.abiflags.startswith("d"): + sys.pydebug = True + else: + sys.pydebug = False + def get_library_dir(): # Find the path to the built apt_pkg and apt_inst extensions if not os.path.exists("../build"): -- cgit v1.2.3