summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/tdb/pytdb.c4
-rw-r--r--lib/tdb/python/tests/simple.py8
2 files changed, 11 insertions, 1 deletions
diff --git a/lib/tdb/pytdb.c b/lib/tdb/pytdb.c
index 58db1a8a6d..d904e47e83 100644
--- a/lib/tdb/pytdb.c
+++ b/lib/tdb/pytdb.c
@@ -409,7 +409,9 @@ static PyGetSetDef tdb_object_getsetters[] = {
static PyObject *tdb_object_repr(PyTdbObject *self)
{
- return PyString_FromFormat("Tdb('%s')", tdb_name(self->ctx));
+ return PyString_FromFormat("Tdb('%s')",
+ (tdb_get_flags(self->ctx) & TDB_INTERNAL) ? "<internal>"
+ : tdb_name(self->ctx));
}
static void tdb_object_dealloc(PyTdbObject *self)
diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py
index 5db824753b..258a486f91 100644
--- a/lib/tdb/python/tests/simple.py
+++ b/lib/tdb/python/tests/simple.py
@@ -28,6 +28,14 @@ class CloseTdbTests(TestCase):
self.tdb.close()
+class InternalTdbTests(TestCase):
+ def test_repr(self):
+ self.tdb = tdb.Tdb("whatever", tdb_flags=tdb.INTERNAL)
+
+ # repr used to crash on internal db
+ self.assertEquals(repr(self.tdb), "Tdb('<internal>')")
+
+
class SimpleTdbTests(TestCase):
def setUp(self):