[IronPython] Dealing with exceptions in an extension module
jdhardy at gmail.com
Fri Apr 30 23:49:57 CEST 2010
I'm trying to fix up the exceptions for the _sqlite3 module I'm
implementing. The dbapi spec (PEP 249) requires a very specific
exception hierarchy, including exceptions derived from StandardError.
My initial version just used C# Exception classes, but StandardError
is not a normal class, so that was insufficient. I looked into how the
existing modules did it (using PythonContext.EnsureModuleException)
and started to implement that but I've run up against a bit of a
roadblock: PythonExceptions.CreateThrowable is internal. It's not a
problem for anything in IronPython.Modules, of course, because of the
accursed InternalsVisibleToAttribute, but that doesn't help me much
Is there a public way to create and throw a Python exception (i.e. a
BaseException instance)? For now I'm just using reflection, but I
would like a better way.
On a related note, there's too much stuff that's used in
IronPython.Modules but is internal in IronPython - it makes it hard to
figure out the "proper" (public) way to do things.
More information about the Ironpython-users