[IronPython] Traceback Objects?
Gary Stephenson
garys at ihug.com.au
Tue Sep 5 11:55:50 CEST 2006
Thanks for that, Mark.
For some reason I was unable to find the message from Dino that you quoted.
As for the CPython thing, I'm trying to stick to a policy of only using ipy
and C# (and as little C# as possible).
cheers,
gary
----- Original Message -----
From: "Mark Rees" <mark.john.rees at gmail.com>
To: "Discussion of IronPython" <users at lists.ironpython.com>
Sent: Tuesday, September 05, 2006 6:24 PM
Subject: Re: [IronPython] Traceback Objects?
Was hoping someone with more knowledge would answer your question but
think theres been a holiday in the US. I cannot say if IP behaves the
same as CPython in this case, but I was going to say that using the
the standard traceback module allows printing of the stack. Even one
of the IP team said it in a email:
>----------
>From: Dino Viehland
>Sent: Wednesday, July 12, 2006 11:54 AM
>To: Discussion of IronPython
>Subject: Re: [IronPython] Getting a call stack from an exception?
>
>Tracebacks are the correct way to do this, I recommend you install
the standard Python library against IronPython to make this really
useful – then you can do import traceback and use its handy functions
(otherwise you'll be walking the traceback list in sys.exc_info()
which won't be much fun).
>
But running this code:
import sys, traceback
def test():
try:
raise Exception()
except:
print traceback.format_exc()
print traceback.print_stack()
test()
I got this:
'NoneType' object has no attribute 'tb_frame'
at IronPython.Runtime.Types.DynamicType.GetAttr(ICallerContext context,
Objec
t self, SymbolId name)
at IronPython.Runtime.Operations.Ops.GetAttr(ICallerContext context,
Object o
, SymbolId name)
at traceback.print_stack$f14(Object f, Object limit, Object file) in
E:\Pytho
n24\Lib\traceback.py:line 246
at IronPython.Runtime.Calls.Function3.Call(ICallerContext context)
at IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext
context,
Object func)
at test$f159##120(ModuleScope )
at IronPython.Runtime.Calls.CallTarget0.Invoke()
at IronPython.Runtime.Calls.Function0.Call(ICallerContext context)
at IronPython.Runtime.Operations.Ops.CallWithContext(ICallerContext
context,
Object func)
at <stdin>##121(ModuleScope )
at IronPython.Hosting.CompiledCodeDelegate.Invoke(ModuleScope
moduleScope)
at IronPython.Hosting.CompiledCode.Run(ModuleScope moduleScope)
at IronPython.Hosting.PythonEngine.ExecuteToConsole(String text,
EngineModule
engineModule, IDictionary`2 locals)
at IronPython.Hosting.PythonEngine.ExecuteToConsole(String text)
at IronPythonConsole.PythonCommandLine.DoOneInteractive()
at IronPythonConsole.PythonCommandLine.<RunInteractiveLoop>b__6(Boolean&
cont
inueInteractionArgument)
at
IronPythonConsole.PythonCommandLine.TryInteractiveAction(InteractiveAction
interactiveAction, Boolean& continueInteraction)
AttributeError: 'NoneType' object has no attribute 'tb_frame'
So maybe it is a bug, or you can use traceback for simple things but
not printing the stack or maybe it only affects Australians like you
and me.
Regards
Mark
On 9/5/06, Gary Stephenson <garys at ihug.com.au> wrote:
> My third attempt at asking this question (as the previous two went through
> to the 'keeper) ...
>
> Is the following considered a bug in IronPython, or am I doing something
> wrong?
>
> import sys
>
> def test():
> try:
> raise Exception()
> except Exception, oErr:
> print sys.exc_info()[2] # None in ipy, traceback object in
> CPython
> print sys.exc_traceback # ditto..
>
> test()
>
> Regardless of the answer to the previous question, a printout of a stack
> trace does currently occur on an unhandled exception. Other than
> redirecting stderr (which I _assume_ would work), is there an easy way of
> logging the traceback message to a file?
>
> Apologies if I am asking unwelcome nooby questions. Should I perhaps be
> asking on another forum, and if so, which?
>
> thanks in advance,
>
> gary
>
> _______________________________________________
> users mailing list
> users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
_______________________________________________
users mailing list
users at lists.ironpython.com
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
More information about the Ironpython-users
mailing list