]> granicus.if.org Git - python/commit
Hopefully fix the profiler right. Add a test suite that checks that
authorGuido van Rossum <guido@python.org>
Thu, 4 Oct 2001 00:58:24 +0000 (00:58 +0000)
committerGuido van Rossum <guido@python.org>
Thu, 4 Oct 2001 00:58:24 +0000 (00:58 +0000)
commitf137f75ab82019b7b4db6d45bd69e2c0b155b2eb
tree263ca955ba5b7350a9eaf4385065eb107322feae
parent6f3d82693ab9a4b0f4f366f7ead4e50cd8e4934e
Hopefully fix the profiler right.  Add a test suite that checks that
it deals correctly with some anomalous cases; according to this test
suite I've fixed it right.

The anomalous cases had to do with 'exception' events: these aren't
generated when they would be most helpful, and the profiler has to
work hard to recover the right information.  The problems occur when C
code (such as hasattr(), which is used as the example here) calls back
into Python code and clears an exception raised by that Python code.
Consider this example:

    def foo():
        hasattr(obj, "bar")

Where obj is an instance from a class like this:

    class C:
        def __getattr__(self, name):
            raise AttributeError

The profiler sees the following sequence of events:

    call (foo)
    call (__getattr__)
    exception (in __getattr__)
    return (from foo)

Previously, the profiler would assume the return event returned from
__getattr__. An if statement checking for this condition and raising
an exception was commented out...  This version does the right thing.
Lib/profile.py
Lib/test/output/test_profile [new file with mode: 0644]
Lib/test/test_profile.py [new file with mode: 0644]