summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2010-12-12 14:26:26 +0100
committerJulian Andres Klode <jak@debian.org>2010-12-12 14:26:26 +0100
commit88cbcaa5a0fcffd319004b85287f0de42f622571 (patch)
tree05db30be0c16f1b58c3ff8f1e4b2dd8a5d3c3eb7
parenteca74f2d3cdfc32ac9c8daeb50bba70da8590d91 (diff)
parent6a05a8302c405c4c8d1b59f6be8c2d0974c6ce1e (diff)
downloadpython-apt-88cbcaa5a0fcffd319004b85287f0de42f622571.tar.gz
Merge from mvo
* python/generic.h: - set Object to NULL in CppDeallocPtr * python/depcache.cc: - don't run "actiongroup.release()" if the object was already deallocated * tests/test_apt_cache.py: - fix tests to work if apt compressed indexes are enabled
-rw-r--r--debian/changelog10
-rw-r--r--python/depcache.cc3
-rw-r--r--python/generic.h4
-rw-r--r--tests/test_all.py8
-rw-r--r--tests/test_apt_cache.py17
5 files changed, 30 insertions, 12 deletions
diff --git a/debian/changelog b/debian/changelog
index d815e6e0..7a6e854c 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,9 +1,19 @@
python-apt (0.7.100.1) UNRELEASED; urgency=low
+ [ Julian Andres Klode ]
* python/generic.h: Fix a memory leak (leaking on every unicode string).
* debian/control: add Replaces to python-apt-common, python3-apt; to
avoid file conflicts with files previously in python-apt (Closes: #605136).
+ [ Michael Vogt ]
+ * python/generic.h:
+ - set Object to NULL in CppDeallocPtr
+ * python/depcache.cc:
+ - don't run "actiongroup.release()" if the object was already
+ deallocated
+ * tests/test_apt_cache.py:
+ - fix tests to work if apt compressed indexes are enabled
+
-- Julian Andres Klode <jak@debian.org> Tue, 07 Dec 2010 15:01:08 +0100
python-apt (0.7.100) unstable; urgency=low
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<pkgDepCache::ActionGroup*>(Self);
- ag->release();
+ if (ag != NULL)
+ ag->release();
Py_RETURN_FALSE;
}
diff --git a/python/generic.h b/python/generic.h
index fc2a6c06..ce9e5091 100644
--- a/python/generic.h
+++ b/python/generic.h
@@ -204,8 +204,10 @@ void CppDeallocPtr(PyObject *iObj)
std::cerr << "=== DEALLOCATING " << iObj->ob_type->tp_name << "*+ ===\n";
#endif
CppPyObject<T> *Obj = (CppPyObject<T> *)iObj;
- if (!((CppPyObject<T>*)Obj)->NoDelete)
+ if (!((CppPyObject<T>*)Obj)->NoDelete) {
delete Obj->Object;
+ Obj->Object = NULL;
+ }
CppClear<T>(iObj);
iObj->ob_type->tp_free(iObj);
}
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"):
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__":