summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2013-10-14 17:21:55 +0200
committerJulian Andres Klode <jak@debian.org>2013-10-14 17:24:01 +0200
commitca19a1977a715359471d104a2adbecfa540f3af5 (patch)
treeb76dda1f8e04d3f6c805e3242ba9cdb2637fe9a4
parent1d62185fb1eb7b9523ec45666c3d96863b91e9af (diff)
downloadpython-apt-ca19a1977a715359471d104a2adbecfa540f3af5.tar.gz
python/indexrecords.cc: IndexRecords.load() needs to accept bytes as well
-rw-r--r--python/indexrecords.cc4
-rw-r--r--tests/test_paths.py29
2 files changed, 31 insertions, 2 deletions
diff --git a/python/indexrecords.cc b/python/indexrecords.cc
index ae8671ab..9446fad1 100644
--- a/python/indexrecords.cc
+++ b/python/indexrecords.cc
@@ -37,8 +37,8 @@ static PyObject *indexrecords_new(PyTypeObject *type,PyObject *Args,
static PyObject *indexrecords_load(PyObject *self,PyObject *args)
{
- const char *filename;
- if (PyArg_ParseTuple(args, "s", &filename) == 0)
+ PyApt_Filename filename;
+ if (PyArg_ParseTuple(args, "O&", PyApt_Filename::Converter, &filename) == 0)
return 0;
indexRecords *records = GetCpp<indexRecords*>(self);
return HandleErrors(PyBool_FromLong(records->Load(filename)));
diff --git a/tests/test_paths.py b/tests/test_paths.py
new file mode 100644
index 00000000..d83ef14b
--- /dev/null
+++ b/tests/test_paths.py
@@ -0,0 +1,29 @@
+#
+# Test that both unicode and bytes path names work
+#
+import unittest
+
+import apt_pkg
+
+
+class TestPath(unittest.TestCase):
+
+ def setUp(self):
+ apt_pkg.init()
+
+ def test_index_records(self):
+ index = apt_pkg.IndexRecords()
+ index.load(u"./data/misc/foo_Release")
+ index.load(b"./data/misc/foo_Release")
+
+ hash1, size1 = index.lookup(u"main/i18n/Index")
+ hash2, size2 = index.lookup(b"main/i18n/Index")
+
+ self.assertEqual(size1, size2)
+ self.assertEqual(str(hash1), str(hash2))
+ self.assertEqual(str(hash1), ("SHA256:fefed230e286d832ab6eb0fb7b72"
+ + "442165b50df23a68402ae6e9d265a31920a2"))
+
+
+if __name__ == '__main__':
+ unittest.main()