[IronPython] Setting tb_next

Michael Foord fuzzyman at voidspace.org.uk
Sat Jun 14 01:04:42 CEST 2008


Dan Eloff wrote:
> 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?
>   

Why on *earth* does Jinja need to do that? It's truly horrible. Python 
is a dynamic enough language that there are hundreds of way achieving 
even the strangest of behaviour without resorting to stupidity like 
that. Bug them to change it...

Michael Foord

> 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
>   


-- 
http://www.ironpythoninaction.com/
http://www.theotherdelia.co.uk/
http://www.voidspace.org.uk/
http://www.ironpython.info/
http://www.resolverhacks.net/




More information about the Ironpython-users mailing list