summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2009-06-08 17:55:23 +0200
committerJulian Andres Klode <jak@debian.org>2009-06-08 17:55:23 +0200
commit6bad14680b22f2bffbe9a3a10a954acaf13a7ad5 (patch)
tree32b85e66bf6af209df4c6b6bb1944b569058817f
parent33293ab8c53a9b1427012c297f288972e11ea3bb (diff)
downloadpython-apt-6bad14680b22f2bffbe9a3a10a954acaf13a7ad5.tar.gz
python/indexrecords.cc: Swap tuple elements in lookup, and raise KeyError when none is found.
-rw-r--r--python/indexrecords.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/python/indexrecords.cc b/python/indexrecords.cc
index e6099a69..917c3bbf 100644
--- a/python/indexrecords.cc
+++ b/python/indexrecords.cc
@@ -45,7 +45,7 @@ static PyObject *IndexRecords_Load(PyObject *self,PyObject *args)
}
static const char *IndexRecords_Lookup_doc = "lookup(metakey)\n\n"
- "Lookup the filename given by metakey, return a tuple (size,hash).\n"
+ "Lookup the filename given by metakey, return a tuple (hash, size).\n"
"The hash part is a HashString() object.";
static PyObject *IndexRecords_Lookup(PyObject *self,PyObject *args)
{
@@ -54,8 +54,13 @@ static PyObject *IndexRecords_Lookup(PyObject *self,PyObject *args)
return 0;
indexRecords *records = GetCpp<indexRecords*>(self);
const indexRecords::checkSum *result = records->Lookup(keyname);
- return Py_BuildValue("(iO)",result->Size,
- PyHashString_FromCpp((HashString*)&result->Hash));
+ if (result == 0) {
+ PyErr_SetString(PyExc_KeyError,keyname);
+ return 0;
+ }
+ return Py_BuildValue("(Oi)",
+ PyHashString_FromCpp((HashString*)&result->Hash),
+ result->Size);
}
static PyObject *IndexRecords_GetDist(PyObject *self)