[IronPython] Line numbers in snippets...

Alex Henderson alex at syzmk.com
Mon May 15 22:48:05 CEST 2006


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




More information about the Ironpython-users mailing list