1
2
3
4 """
5 Exceptions and exception handling.
6
7 @var orig_excepthook: The original excepthook (as of the time this
8 module is first loaded). This just serves as a backup if it needs to
9 be restored.
10 """
11
12 from decs import *
13 import sys
14
15 orig_excepthook = sys.excepthook
16
18 """
19 The default exception handler (prints a stack trace and the
20 exception message), except it does not actually terminate the
21 thread.
22 """
23 orig_excepthook( *sys.exc_info() )
24
26
28 """
29 Wrap an object and all of its methods with per-access
30 invariants-checking.
31
32 @todo: This code is incomplete and does not actually check
33 invariants yet!
34 """
36 def check_invariants():
37
38 for invariant in self.invariants:
39 if not invariant():
40 raise FailedInvariant()
41 GenericWrapper.__init__(self, obj, None, check_invariants, ignore)
42