[IronPython] Setting tb_next
Dino Viehland
dinov at exchange.microsoft.com
Sat Jun 14 00:24:44 CEST 2008
I'd imagine Cecil would work but it might be overkill - you could just use .NET reflection:
try:
raise Exception()
except:
import sys
tb = sys.exc_info()[2]
tbtype = type(tb)
import clr
import System
clr.GetClrType(tbtype).GetField('_next', System.Reflection.BindingFlags.NonPublic|System.Reflection.BindingFlags.Instance).SetValue(tb, None)
Just replace None w/ the value you want to set it to. For 1.x change '_next' to 'next'.
-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Tim Riley
Sent: Friday, June 13, 2008 3:16 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Setting tb_next
Could you use something like Cecil for this?
On 6/13/08, Dan Eloff <dan.eloff at gmail.com> wrote:
> It's readonly in Python, and that's the way it's meant to be. But I'm
> porting Jinja2 to IronPython (Silverlight hopefully) and Jinja uses
> ctypes to dig deep into CPython's guts and make a function for setting
> tb_next on traceback objects. Playing by the same dirty, no holds
> barred rules, is there a way to set tb_next on traceback objects in
> IronPython?
>
> Thanks,
> -Dan
> _______________________________________________
> Users mailing list
> Users at lists.ironpython.com
> http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
>
--
Sent from Gmail for mobile | mobile.google.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