Brian Lloyd a écrit :

I am using pythonNet with a great pleasure, thanks a lot for that piece of work.

IMHO, a wiki would be very very useful for this project, as I would be ready to contribute...

One question:

How do I print out managed exceptions full stack trace?



Hi Stan -


A trick you might be able to use is:

print CLR.System.Environment.StackTrace



unfortunately not:

try:
     #do stuff that throws exception in the CLR
   except:
     print Environment.StackTrace

gives what printed below, wich is fairly unusable.

at System.Environment.GetStackTrace(Exception e)^M
at System.Environment.GetStackTrace(Exception e)^M
at System.Environment.get_StackTrace()^M
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlag
s invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean i
sBinderDefault, Assembly caller, Boolean verifyAccess)^M
at System.Reflection.RuntimeMethodInfo.InternalInvoke(Object obj, BindingFlag
s invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean v
erifyAccess)^M
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invoke
Attr, Binder binder, Object[] parameters, CultureInfo culture)^M
at System.Reflection.RuntimePropertyInfo.GetValue(Object obj, Object[] index)


at Python.Runtime.PropertyObject.tp_descr_get(IntPtr ds, IntPtr ob, IntPtr tp
)^M
at Python.Runtime.Runtime.Py_Main(Int32 argc, String[] argv)^M
at Python.Runtime.PythonConsole.Main(String[] args)


Exceptions are in kind of an odd state right now - the C Python runtime really wants exceptions to be old-style Python classes, and the fact that managed exceptions aren't causes some problems in the current version of Python for .NET. I'm still hoping to find a sneaky way around it or successfully lobby the Python devs to remove this restriction for a future Python version.

Brian Lloyd [EMAIL PROTECTED]
V.P. Engineering 540.361.1716 Zope Corporation http://www.zope.com








_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet

Reply via email to