The problem was tdb->name is NULL for TDB_INTERNAL databases, and
so it was crashing ...
#0 0xb76944f3 in strlen () from /lib/i686/cmov/libc.so.6
#1 0x0809862b in PyString_FromFormatV (format=0xb72b6a26 "Tdb('%s')", vargs=0xbfc26a94 "")
at ../Objects/stringobject.c:211
#2 0x08098888 in PyString_FromFormat (format=0xb72b6a26 "Tdb('%s')") at ../Objects/stringobject.c:358
#3 0xb72b65f2 in tdb_object_repr (self=0xb759e060) at ./pytdb.c:439
Cc: 597089@bugs.debian.org
Signed-off-by: Kirill Smelkov <kirr@mns.spb.ru>
Signed-off-by: Jelmer Vernooij <jelmer@samba.org>
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)
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):
super(SimpleTdbTests, self).setUp()