diff options
author | R David Murray <rdmurray@bitdance.com> | 2013-04-19 12:57:54 -0400 |
---|---|---|
committer | R David Murray <rdmurray@bitdance.com> | 2013-04-19 12:57:54 -0400 |
commit | f097f175dd3385e6e43842680932b32cbc50365d (patch) | |
tree | 9f0792a864e03c4e1ed58bb4f0819bfb40be2d0f /Lib/test | |
parent | 24aa15959b0f8b540dc4c2eacf31755e506ab3b5 (diff) | |
parent | 3583761bcd3ebc85207f555017e06f2007cd0db0 (diff) | |
download | cpython-git-f097f175dd3385e6e43842680932b32cbc50365d.tar.gz |
Merge #17413: make sure settrace funcs get passed exception instances for 'value'.
Patch by Ingrid Cheung and Brendan McLoughlin.
Diffstat (limited to 'Lib/test')
-rw-r--r-- | Lib/test/test_sys_settrace.py | 23 |
1 files changed, 23 insertions, 0 deletions
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"). |