Commits

Armin Rigo  committed 4d1bd9d

(backport) 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.

  • Participants
  • Parent commits 90bb711
  • Branches 2.4

Comments (0)

Files changed (2)

File Lib/profile.py

         "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,
         }
 

File Lib/test/test_profile.py

 # 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)
     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()