[IronPython] Line numbers in snippets...

Alex Henderson alex at syzmk.com
Mon May 15 23:17:52 CEST 2006


Sure thing I'll keep you posted.

Chez,

 - Alex

> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of Dino Viehland
> Sent: Tuesday, 16 May 2006 9:14 a.m.
> To: Discussion of IronPython
> Subject: Re: [IronPython] Line numbers in snippets...
> 
> The stack trace is a little odd in that it's given to you as a linked
> list, and you need to pull it out by indexing into an array, but other
> than that it's straight forward (the only thing different from what I
> showed you below is sys.exc_info()[2].tb_next will get you the 2nd frame
> (and .tb_next on that, and so on)...
> 
> Even if you do get it to work let us know how painful it is, that'll help
> us prioritize considering making this easier in the future.
> 
> Do you want to help develop Dynamic languages on CLR?
> (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-
> 11F0-45DF-8B78-DC1B43134038)
> 
> -----Original Message-----
> From: users-bounces at lists.ironpython.com [mailto:users-
> bounces at lists.ironpython.com] On Behalf Of Alex Henderson
> Sent: Monday, May 15, 2006 2:04 PM
> To: 'Discussion of IronPython'
> Subject: Re: [IronPython] Line numbers in snippets...
> 
> Ahhh... hadn't thought about that ;o) hmm... All the calls to the script
> engine are wrapped up against a simplified engine interface as it is, as
> we
> are attempting to be at least partly script-engine agnostic... so I can't
> see why I couldn't do that, and wrap the exception in one of our own,
> tagged
> with the additional error location info.
> 
> I'll give it a go, and if you don't hear from me then you'll know it
> worked...  I'm a bit of a python newbie, I assume it's easy enough to grab
> hold of a stack trace as well as the line number etc?
> 
> Thanks Dino,
> 
>  - Alex
> 
> > -----Original Message-----
> > From: users-bounces at lists.ironpython.com [mailto:users-
> > bounces at lists.ironpython.com] On Behalf Of Dino Viehland
> > Sent: Tuesday, 16 May 2006 8:55 a.m.
> > To: Discussion of IronPython
> > Subject: Re: [IronPython] Line numbers in snippets...
> >
> > Ahh, ok...  Can you wrap the user code you run w/ more python code?  If
> > you could then you could do:
> >
> > try:
> >         // run user code
> > except:
> >         import sys
> >         print sys.exc_info()[2].tb_lineno
> >         print sys.exc_info()[2].tb_frame.f_code.co_filename
> >
> > That's the Python way to get this information.  Let us know if that
> seems
> > to burdensome.  If so we could look at a way to expose this information
> > via the engine APIs instead of requiring you to create this wrapper.
> >
> >
> > Do you want to help develop Dynamic languages on CLR?
> >
> (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-
> > 11F0-45DF-8B78-DC1B43134038)
> >
> > -----Original Message-----
> > From: users-bounces at lists.ironpython.com [mailto:users-
> > bounces at lists.ironpython.com] On Behalf Of Alex Henderson
> > Sent: Monday, May 15, 2006 1:48 PM
> > To: 'Discussion of IronPython'
> > Subject: Re: [IronPython] Line numbers in snippets...
> >
> > Not quite... my problem is I don't have a PythonSyntaxError thrown, I
> > believe that's because I'm actually receiving a python generated
> > exception,
> > for instance I might catch a PythonNameError when someone incorrectly
> > spells
> > a variable name... and that doesn't contain any information I can use
> the
> > locate where in the snippet string the error occurred... Is there a way
> to
> > get this information out of the PythonEngine itself perhaps?
> >
> > The reason I ask that I just want to implement a feature where by a user
> > can
> > look at a log "view" in our product, see an error has occurred in their
> > script, and be able to double click the entry and navigate to our code
> > editor and be on the right line for fixing the problem - for this to
> > happen
> > we need to be able to extract some details of where the error occurred
> > when
> > using PythonEngine.Execute...
> >
> > Any ideas I would be greatly appreciated... :)
> >
> > Chez,
> >
> >  - Alex
> >
> > > -----Original Message-----
> > > From: users-bounces at lists.ironpython.com [mailto:users-
> > > bounces at lists.ironpython.com] On Behalf Of Dino Viehland
> > > Sent: Tuesday, 16 May 2006 8:21 a.m.
> > > To: Discussion of IronPython
> > > Subject: Re: [IronPython] Line numbers in snippets...
> > >
> > > We recently made a change so that PythonSyntaxError contains a Line,
> > > Column, Filename, and some other properties on it that you should be
> > able
> > > to get at for this information.  Is that what you're looking for?
> > >
> > >
> > > Do you want to help develop Dynamic languages on CLR?
> > >
> >
> (http://members.microsoft.com/careers/search/details.aspx?JobID=6D4754DE-
> > > 11F0-45DF-8B78-DC1B43134038)
> > > -----Original Message-----
> > > From: users-bounces at lists.ironpython.com [mailto:users-
> > > bounces at lists.ironpython.com] On Behalf Of Alex Henderson
> > > Sent: Monday, May 15, 2006 1:09 PM
> > > To: 'Discussion of IronPython'
> > > Subject: [IronPython] Line numbers in snippets...
> > >
> > > We've been using IronPython as a scripting engine in one of our
> products
> > > that's in development for a while now, works great :)
> > >
> > > However when executing code which has syntax errors in it we can't
> seem
> > to
> > > get line numbers back from the exception, or find any compilation
> > context
> > > we
> > > can examine for a list of errors - which makes it difficult to
> diagnose
> > > problems obviously.
> > >
> > > I figure this is probably a limitation of the execute method, unless
> > I've
> > > missed something... is there a different approach we could use where
> we
> > > will
> > > get line numbers when an error occurs?
> > >
> > > Chez,
> > >
> > >  - Alex
> > >
> > > _______________________________________________
> > > 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
> > _______________________________________________
> > 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 Ironpython-users mailing list