From 277a1b229cf1b456560a50d021e2eaf2158e5134 Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Sun, 19 Sep 2010 13:53:21 +0400 Subject: pytdb: Fix repr segfault for internal db 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 Signed-off-by: Jelmer Vernooij --- lib/tdb/python/tests/simple.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'lib/tdb/python') diff --git a/lib/tdb/python/tests/simple.py b/lib/tdb/python/tests/simple.py index 5db824753b1..258a486f91a 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('')") + + class SimpleTdbTests(TestCase): def setUp(self): -- cgit v1.2.1