Commit d3db5387 authored by JINMEI Tatuya's avatar JINMEI Tatuya
Browse files

[1372] fixed an overlooked bug in #1333: needed to catch C++ exceptions in

DataSourceClient.get_journal_reader().
parent 2ab2fd55
......@@ -182,19 +182,32 @@ DataSourceClient_getJournalReader(PyObject* po_self, PyObject* args) {
if (PyArg_ParseTuple(args, "O!kk", &name_type, &name_obj,
&begin_obj, &end_obj)) {
pair<ZoneJournalReader::Result, ZoneJournalReaderPtr> result =
self->cppobj->getInstance().getJournalReader(
PyName_ToName(name_obj), static_cast<uint32_t>(begin_obj),
static_cast<uint32_t>(end_obj));
PyObject* po_reader;
if (result.first == ZoneJournalReader::SUCCESS) {
po_reader = createZoneJournalReaderObject(result.second, po_self);
} else {
po_reader = Py_None;
Py_INCREF(po_reader); // this will soon be released
try {
pair<ZoneJournalReader::Result, ZoneJournalReaderPtr> result =
self->cppobj->getInstance().getJournalReader(
PyName_ToName(name_obj), static_cast<uint32_t>(begin_obj),
static_cast<uint32_t>(end_obj));
PyObject* po_reader;
if (result.first == ZoneJournalReader::SUCCESS) {
po_reader = createZoneJournalReaderObject(result.second,
po_self);
} else {
po_reader = Py_None;
Py_INCREF(po_reader); // this will soon be released
}
PyObjectContainer container(po_reader);
return (Py_BuildValue("(iO)", result.first, container.get()));
} catch (const isc::NotImplemented& ex) {
PyErr_SetString(getDataSourceException("NotImplemented"),
ex.what());
} catch (const DataSourceError& ex) {
PyErr_SetString(getDataSourceException("Error"), ex.what());
} catch (const std::exception& ex) {
PyErr_SetString(getDataSourceException("Error"), ex.what());
} catch (...) {
PyErr_SetString(getDataSourceException("Error"),
"Unexpected exception");
}
PyObjectContainer container(po_reader);
return (Py_BuildValue("(iO)", result.first, container.get()));
}
return (NULL);
}
......
......@@ -783,6 +783,15 @@ class JournalRead(unittest.TestCase):
# ZoneJournalReader can only be constructed via a factory
self.assertRaises(TypeError, ZoneJournalReader)
def test_journal_reader_old_schema(self):
# The database doesn't have a "diffs" table.
dbfile = TESTDATA_PATH + 'test.sqlite3.nodiffs'
client = isc.datasrc.DataSourceClient("sqlite3",
"{ \"database_file\": \"" + \
dbfile + "\" }")
self.assertRaises(isc.datasrc.Error, client.get_journal_reader,
self.zname, 0, 1)
if __name__ == "__main__":
isc.log.init("bind10")
isc.log.resetUnitTestRootLogger()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment