[Python-bugs-list] [ python-Bugs-467571 ] profile.py mishandles exceptions (original) (raw)
noreply@sourceforge.net noreply@sourceforge.net
Thu, 04 Oct 2001 07:10:18 -0700
- Previous message: [Python-bugs-list] [ python-Bugs-467811 ] Inability to "see" some module content
- Next message: [Python-bugs-list] [ python-Bugs-467145 ] Python 2.2a4 build problem on HPUX 11.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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: Closed Resolution: Fixed Priority: 5 Submitted By: Stephen A. Langer (slanger) Assigned to: Guido van Rossum (gvanrossum) 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-04 07:10
Message: Logged In: YES user_id=340060
Yes, profile.py from the current CVS fixes the problems. Thanks!
-- Steve
Comment By: Guido van Rossum (gvanrossum) Date: 2001-10-03 18:11
Message: Logged In: YES user_id=6380
Steve, can you try again with the profile.py from current CVS? It works with Python 1.5.2 through 2.2. If I understand your test program well, this fixes both problems.
(We don't always fix deep problems this quickly, but it so happens that this had just come up at Zope Corp. ;-)
Closing this as fixed now (ever the optimist...).
Comment By: Fred L. Drake, Jr. (fdrake) Date: 2001-10-03 14:47
Message: Logged In: YES user_id=3066
The example code seems to be attached now; thanks!
We're increasingly aware of the problems with the profiler. We expect to take care of this in the "right way" for Python 2.2 (by changing the events passed to the profiler) so that the stack management is reliable. We hope to also have a working profiler for Python 2.1.x as well, and sooner rather than later.
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
- Previous message: [Python-bugs-list] [ python-Bugs-467811 ] Inability to "see" some module content
- Next message: [Python-bugs-list] [ python-Bugs-467145 ] Python 2.2a4 build problem on HPUX 11.0
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]