diff --git a/ChangeLog b/ChangeLog index 47ee1c776..cc2e1750c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +2005-04-06 Richard Taylor + * src/GrampsDBCallback.py: improved error reporting when there is an error in + a callback function. Added unittest for exception in callback function. + 2005-04-06 Martin Hawlisch * src/gramps_main.py (post_load): Emit "database-changed" signal instead of calling change_db(). @@ -11,7 +15,7 @@ * src/SourceView.py (__init__): dont call change_cb because on initialisation there is no real database and this will be done by the signal. -2005-04-04 Richard Taylor +2005-04-06 Richard Taylor * src/plugins/ScratchPad.py: made clear buttons sensitive to contents of list and current selection. Added support for PERSON_LINK dnd. * src/DdTargets.py: added PERSON_LINK target and simplified generation of diff --git a/src/GrampsDBCallback.py b/src/GrampsDBCallback.py index 9ee06e5d7..3d4084a88 100644 --- a/src/GrampsDBCallback.py +++ b/src/GrampsDBCallback.py @@ -35,8 +35,9 @@ to communicate events to any callback methods in either the database code or the UI code. """ -import types import sys +import types +import traceback log = sys.stderr.write @@ -364,7 +365,10 @@ class GrampsDBCallback(object): else: self._log("Warning: badly formed entry in callback map.\n") except: - self._log("Warning: exception occured in callback function.\n") + log("%s: %s" % (self.__class__.__name__, + "Warning: exception occured in callback function.\n")) + log("%s: %s" % (self.__class__.__name__, + "".join(traceback.format_exception(*sys.exc_info())))) # # instance signals control methods @@ -434,6 +438,40 @@ if __name__ == "__main__": assert len(rl) == 1, "No signal emitted" assert rl[0] == 1, "Wrong argument recieved" + + def test_exception_catch(self): + + class TestSignals(GrampsDBCallback): + + __signals__ = { + 'test-signal' : (int,) + } + + rl = [] + def fn(i,r=rl): + rl.append(i) + + def borked(i): + rubish.append(i) + + t = TestSignals() + + def null(s): + pass + + + global log + _log = log + log = null + + t.connect('test-signal',borked) + t.connect('test-signal',fn) + t.emit('test-signal',(1,)) + log = _log + + assert len(rl) == 1, "No signal emitted" + assert rl[0] == 1, "Wrong argument recieved" + def test_disconnect(self): class TestSignals(GrampsDBCallback):