From
[email protected] Tue Oct 13 13:09:38 1998
Date: Tue, 13 Oct 1998 09:46:22 +0100
From: Johannes Stezenbach <
[email protected]>
Organization: Propack Data GmbH, D-76131 Karlsruhe
To:
[email protected]
Subject: Re: sys.settrace questions
Newsgroups: comp.lang.python
X-Organization: Propack Data GmbH, D-76131 Karlsruhe
Greg Stein wrote:
>
> Milan Zamazal wrote in message <
[email protected]>...
> >
> >1. The `pdb.doc' file says, that `arg' is in case of `call' the
> > argument list to the function, however it is `None' in my example.
> > Is it bug of `sys.settrace' or `pdb.doc'? How can I receive the
> > function arguments?
..
> It looks like the code may have passed the arguments at some point in
> history, but I'd guess that stopped when keyword arguments were introduced.
> That complicates "what are the arguments?" immensely.
I once wanted to do automatic white box tests, i.e. write
a log of all function calls together with arguments and
return values, *without* cluttering my code with print
statements.
After studying pdb.py and profile.py I came up with the
following module.
It is used like this:
-----------------
import wbtrace.py
wbtrace.start()
..<your code goes here>
---------------------
The output is somewhat voluminous because it
covers all the standard library modules.
During testing I had one stack overflow
problem with a faulty __getattr__ implementation:
wbtrace.py attempts to print constructor arguments
before the constructor body ran. Python the internally calls
__getattr__. If __getattr__ relies on variables set by
the constructor, __getattr__ fails.
Otherwise wbtrace.py works like I wanted it to.