[IronPython] Setting tb_next

Dino Viehland dinov at exchange.microsoft.com
Fri Jun 13 16:10:59 PDT 2008


Oh, sorry, I overlooked the Silverlight part.  There's no way to do this there :(

-----Original Message-----
From: users-bounces at lists.ironpython.com [mailto:users-bounces at lists.ironpython.com] On Behalf Of Dan Eloff
Sent: Friday, June 13, 2008 4:03 PM
To: Discussion of IronPython
Subject: Re: [IronPython] Setting tb_next

That's looks easy, except it won't work in Silverlight. You can only
access public members in Silverlight, even via reflection. Do I have
any options in Silverlight?

Thanks,
-Dan

On Fri, Jun 13, 2008 at 5:24 PM, Dino Viehland
<dinov at exchange.microsoft.com> wrote:
> 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
> _______________________________________________
> 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 Users mailing list