diff options
author | Armin Rigo <arigo@tunes.org> | 2005-09-20 18:50:13 (GMT) |
---|---|---|
committer | Armin Rigo <arigo@tunes.org> | 2005-09-20 18:50:13 (GMT) |
commit | f87902448753ece981b5df938c070320705e5dec (patch) | |
tree | c58850543110002296115b770dcf6eefa6b51e23 /Lib | |
parent | 630db60a5533a3267e2cc07047498fad604e3c91 (diff) | |
download | cpython-f87902448753ece981b5df938c070320705e5dec.zip cpython-f87902448753ece981b5df938c070320705e5dec.tar.gz cpython-f87902448753ece981b5df938c070320705e5dec.tar.bz2 |
test and fix for buggy handling of exceptions raised by C functions,
causing the profiler to crash on an AssertionError if the same Python
function catches multiple exceptions from C functions.
Diffstat (limited to 'Lib')
-rwxr-xr-x | Lib/profile.py | 2 | ||||
-rw-r--r-- | Lib/test/test_profile.py | 23 |
2 files changed, 22 insertions, 3 deletions
diff --git a/Lib/profile.py b/Lib/profile.py index 5a29bd6..b6048aa 100755 --- a/Lib/profile.py +++ b/Lib/profile.py @@ -368,7 +368,7 @@ class Profile: "exception": trace_dispatch_exception, "return": trace_dispatch_return, "c_call": trace_dispatch_c_call, - "c_exception": trace_dispatch_exception, + "c_exception": trace_dispatch_return, # the C function returned "c_return": trace_dispatch_return, } diff --git a/Lib/test/test_profile.py b/Lib/test/test_profile.py index e0bda5c..aa0f26c 100644 --- a/Lib/test/test_profile.py +++ b/Lib/test/test_profile.py @@ -10,7 +10,7 @@ from test.test_support import TESTFN, vereq # included in the profile and would appear to consume all the time.) ticks = 0 -def test_main(): +def test_1(): global ticks ticks = 0 prof = profile.Profile(timer) @@ -95,6 +95,25 @@ def test_2(): vereq (x, 1) os.unlink (TESTFN) +def test_3(): + result = [] + def testfunc1(): + try: len(None) + except: pass + try: len(None) + except: pass + result.append(True) + def testfunc2(): + testfunc1() + testfunc1() + profile.runctx("testfunc2()", locals(), locals(), TESTFN) + vereq(result, [True, True]) + os.unlink(TESTFN) + +def test_main(): + test_1() + test_2() + test_3() + if __name__ == "__main__": test_main() - test_2() |