I was trying to suggest to the IP developers that access to file, line and 
perhaps column should be readily available from any exception.  Your response 
suggests that I might not have said so clearly.

When there's a Name Error, it's often possible to work on solving the problem 
without line number info -- you can look at the script for where the bad name 
is used.  (In the particular case of Name Error, the code that's wrong isn't 
necessarily on the line that was running when the exception occurs -- if you 
define a method named SpelledRite and other code calls method SpelledRight, the 
error will be on the line that does the call, regardless of which name you 
intended to use.)

At 04:24 PM 5/16/2006, Alex Henderson wrote
>The name error exception does give you the name causing the grief, but the
>line number isn't available, not without doing a little extra work (as Dino
>outlined) by wrapping up the evaluation of the snippet within a python
>try... except block and pulling some of the info in from sys.exc_info() and
>exposing it to the application hosting the PythonEngine.  
>
>The name isn't really enough for us, we need access to the line number and a
>python stack trace so clients can better analyse what went wrong (we aren't
>evaluating one line exceptions, these are like 100 line snippets)... and
>there are some other errors where the information provided in the exception
>makes it very difficult to resolve the issue without access to the
>additional info.
>
>Chez,
>
> - Alex
>
>> -----Original Message-----
>> From: [EMAIL PROTECTED] [mailto:users-
>> [EMAIL PROTECTED] On Behalf Of J. Merrill
>> Sent: Wednesday, 17 May 2006 3:50 a.m.
>> To: Discussion of IronPython
>> Subject: Re: [IronPython] Line numbers in snippets...
>> 
>> Shouldn't all Python errors (not just Synax) provide the filename & line
>> number?  Column number would often be less important, particularly for
>> run-time (vs compile-time -- e.g. not Syntax) errors.
>> 
>> As a practical matter, how can it be that a PythonNameError exception
>> doesn't provide a way to get at the name that couldn't be resolved?  What
>> more important bit of info could there be?  (But I haven't looked to make
>> sure that the name is NOT available in the latest IP.)
>> 
>> At 04:55 PM 5/15/2006, Dino Viehland wrote
>> >Ahh, ok...  Can you wrap the user code you run w/ more python code?  If
>> you could then you could do:
>> >[snip]


J. Merrill / Analytical Software Corp


_______________________________________________
users mailing list
[email protected]
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com

Reply via email to