From johannes.stezenbach@propack-data.de Tue Oct 13 13:09:38 1998 Date: Tue, 13 Oct 1998 09:46:22 +0100 From: Johannes Stezenbach Organization: Propack Data GmbH, D-76131 Karlsruhe To: python-list@cwi.nl 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 <87zpb3e6z0.fsf@pdm.pvt.net>... > > > >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() ... --------------------- 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. .