[IronPython] Implementing sys.excepthook
dinov at exchange.microsoft.com
Tue Apr 22 23:13:30 CEST 2008
#1 shouldn't be a problem - is this only in the Silverlight builds? Certainly the current desktop IronPython builds allow assignment to sys (both overwriting existing members as well as creating new members). But I'd expect that to have worked more or less forever.
For #2 I believe what we want to do is change Python's PythonContext.FormatException to call excepthook. That's not 100% correct but it'll get pretty close to the right time when excepthook should be called - especially for Silverlight where we won't have another chance to really do it. But Silverlight is going to try and replace your page w/ it's own error page so the end result won't be quite what you want.
I've gone ahead and opened a bug for this (http://www.codeplex.com/IronPython/WorkItem/View.aspx?WorkItemId=16242). If you (and anyone else) could vote on it it'll drive the priority up and we'll fix it sooner rather than later :).
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff
Sent: Tuesday, April 22, 2008 11:20 AM
To: Discussion of IronPython
Subject: [IronPython] Implementing sys.excepthook
I really want to see sys.excepthook in IronPython.
The way I see it there's two problems.
1) You cannot assign to the sys module. So we need a fix or workaround
for that. This is the hard part.
2) We also need to intercept exceptions before they leave IPY and
route them to sys.excepthook, which should be set to __excepthook__ by
default, which needs to be a function that raises the exception in the
way they would have been before interception.
I have no idea how to assess the complexity of these problems, or how
to solve them. I'm quite happy to offer any help required here, but
I'll need some direction.
I have created and embedded an IronPython interactive interpreter into
my Silverlight application. I want to use sys.excepthook to catch
exceptions, print them in the console, and have a combo box of stack
frames that you can jump around and inspect on the fly (like Wing
IDE's debug probe.) It would also work with little or no modification
in WPF applications. I've done similar things with CPython and
wxPython, and found that it really speeds up the development cycle. I
want to have the same functionality in IronPython.
Users mailing list
Users at lists.ironpython.com
More information about the Ironpython-users