From 3583761bcd3ebc85207f555017e06f2007cd0db0 Mon Sep 17 00:00:00 2001 From: R David Murray Date: Fri, 19 Apr 2013 12:56:57 -0400 Subject: #17413: make sure settrace funcs get passed exception instances for 'value'. Patch by Ingrid Cheung and Brendan McLoughlin. --- Lib/test/test_sys_settrace.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'Lib/test') diff --git a/Lib/test/test_sys_settrace.py b/Lib/test/test_sys_settrace.py index 63ae1b7180..f0b0b8290a 100644 --- a/Lib/test/test_sys_settrace.py +++ b/Lib/test/test_sys_settrace.py @@ -458,6 +458,29 @@ class RaisingTraceFuncTestCase(unittest.TestCase): self.fail("exception not propagated") + def test_exception_arguments(self): + def f(): + x = 0 + # this should raise an error + x.no_such_attr + def g(frame, event, arg): + if (event == 'exception'): + type, exception, trace = arg + self.assertIsInstance(exception, Exception) + return g + + existing = sys.gettrace() + try: + sys.settrace(g) + try: + f() + except AttributeError: + # this is expected + pass + finally: + sys.settrace(existing) + + # 'Jump' tests: assigning to frame.f_lineno within a trace function # moves the execution position - it's how debuggers implement a Jump # command (aka. "Set next statement"). -- cgit v1.2.1