[Python-bugs-list] [ python-Bugs-467571 ] profile.py mishandles exceptions
noreply@sourceforge.net
noreply@sourceforge.net
Wed, 03 Oct 2001 11:23:00 -0700
Bugs item #467571, was opened at 2001-10-03 10:51
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=467571&group_id=5470
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Stephen A. Langer (slanger)
Assigned to: Nobody/Anonymous (nobody)
Summary: profile.py mishandles exceptions
Initial Comment:
The profiler in profile.py does not correctly handle
exceptions raised by Python code and caught in built-in functions. For example, if a class has a __getattr__ function that raises an AttributeError, and that exception is caught by hasattr, the profiler never notices that __getattr__ has returned. This is because it never receives an 'exception' event corresponding to the frame in which the exception was caught. The consequence is that subsequent function calls are attributed to the wrong callers, non-recursive functions may be seen as recursive, and the times reported for functions may be vastly incorrect.
I have attached an example program that demonstrates this. I've checked it with Python 1.5.2, 2.0.1 and 2.1.1 on Intel/Linux2.4, and Python 2.1 on SGI/IRIX6.5.
I have also written a replacement for profile.py and pstats.py, which I'd be glad to contribute once I've documented it a bit better. It runs a bit slower than the original, but it does get the right answers (I believe). How does one go about making submissions to the library?
Thanks.
Steve Langer
National Institute of Standards and Technology
stephen.langer@nist.gov
----------------------------------------------------------------------
>Comment By: Stephen A. Langer (slanger)
Date: 2001-10-03 11:22
Message:
Logged In: YES
user_id=340060
This is my last attempt to attach the sample code... if it
doesn't work, send me mail and I'll send the code.
-- Steve (stephen.langer@nist.gov)
----------------------------------------------------------------------
Comment By: Stephen A. Langer (slanger)
Date: 2001-10-03 11:19
Message:
Logged In: YES
user_id=340060
last time I forgot the little checkbox... do I get an
award for the most empty followups?
----------------------------------------------------------------------
Comment By: Stephen A. Langer (slanger)
Date: 2001-10-03 11:18
Message:
Logged In: YES
user_id=340060
Ok, this is ridiculous... I'll see if a different browser
lets me attach a file.
----------------------------------------------------------------------
Comment By: Stephen A. Langer (slanger)
Date: 2001-10-03 11:14
Message:
Logged In: YES
user_id=340060
Second attempt to attach sample code....
----------------------------------------------------------------------
Comment By: Stephen A. Langer (slanger)
Date: 2001-10-03 11:14
Message:
Logged In: YES
user_id=340060
Second attempt to attach sample code....
----------------------------------------------------------------------
You can respond by visiting:
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=467571&group_id=5470