Discussion:
[Python.NET] managed exception stack trace.
Stan Pinte
2005-01-20 17:58:00 UTC
Permalink
hello,

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?

thanks,

Stan.
_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
Brian Lloyd
2005-01-20 18:48:01 UTC
Permalink
Post by Stan Pinte
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...
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

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 brian-***@public.gmane.org
V.P. Engineering 540.361.1716
Zope Corporation http://www.zope.com


_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet
Stan Pinte
2005-02-08 12:40:15 UTC
Permalink
Post by Brian Lloyd
Post by Stan Pinte
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...
How do I print out managed exceptions full stack trace?
Hi Stan -
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)
Post by Brian Lloyd
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.
V.P. Engineering 540.361.1716
Zope Corporation http://www.zope.com
_________________________________________________
Python.NET mailing list - PythonDotNet-+ZN9ApsXKcEdnm+***@public.gmane.org
http://mail.python.org/mailman/listinfo/pythondotnet

Continue reading on narkive:
Loading...