wrapping all class methods
Pedro Rodriguez
pedro_rodriguez at club-internet.fr
Sat Nov 16 07:39:51 EST 2002
Apologies if this is off-topic.
> try:
> origMethod(*args, **kwargs)
This should be:
return origMethod(*args, **kwargs)
> except:
Shouldn't you catch the actual exception:
except Exception, e:
in order to let it go its way up at the end of the exception block:
raise e
Notice that by doing so I get the following trace:
$ python2.2 tbwrap.py
real f 1
[A.f]
Traceback (most recent call last):
File "tbwrap.py", line 5, in wrap_traceback_method
return origMethod(*args, **kwargs)
File "tbwrap.py", line 36, in f
assert x>=0
AssertionError
stack info
name:L2 file:tbwrap.py co_lno:39 lasti:43 f_lno:42
name:L1 file:tbwrap.py co_lno:43 lasti:9 f_lno:44
name:L0 file:tbwrap.py co_lno:45 lasti:9 f_lno:46
name:? file:tbwrap.py co_lno:1 lasti:138 f_lno:47
Traceback (most recent call last):
File "tbwrap.py", line 47, in ?
L0()
File "tbwrap.py", line 46, in L0
L1()
File "tbwrap.py", line 44, in L1
L2()
File "tbwrap.py", line 42, in L2
a.f(-1)
File "tbwrap.py", line 17, in wrap_traceback_method
raise e
AssertionError
Pedro
More information about the Python-list
mailing list