<html>
<body>
You can get the line number info by using Dino's code (calling
sys.exc_info). Are you concerned that the default traceback display
doesn't show the line number?<br><br>
At 01:44 PM 8/21/2006, Matt Beckius wrote<br>
<blockquote type=cite class=cite cite="">No 32bit. I tried manually
setting the TraceBackSupport, but still got the same result:<br>
<br>
IronPython 1.0.60816 on .NET 2.0.50727.42<br>
Copyright (c) Microsoft Corporation. All rights reserved.<br>
>>> import IronPython<br>
>>><br>
>>> IronPython.Compiler.Options.TraceBackSupport = True <br>
>>> def Test():<br>
... print "test"<br>
... int("test")<br>
...<br>
>>> Test()<br>
test<br>
Traceback (most recent call last):<br>
File , line 0, in <stdin>##12<br>
File , line 0, in Test <br>
ValueError: invalid integer number literal<br>
>>><br><br>
<br>
On 8/21/06, <b>Dino Viehland</b>
<<a href="mailto:dinov@exchange.microsoft.com">
dinov@exchange.microsoft.com</a>> wrote: <br>
<dl><br>
<dd>Are you running on a 64-bit machine w/ a 64-bit runtime? By
default we disable trackback support on 64-bit machines (we've hit a
unique bug w/ exception handling there), but it is enabled on 32-bit
machines and should work there. <br><br>
<dd> <br><br>
<dd>If I do:<br><br>
<dd> <br><br>
<dd>import sys<br><br>
<dd>def test2():<br><br>
<dd> try: test()<br><br>
<dd> except ValueError, ex:<br><br>
<dd> global e<br><br>
<dd> import sys<br><br>
<dd> e =
sys.exc_info()<br><br>
<dd> <br><br>
<dd>test2()<br><br>
<dd>e<br><br>
<dd> <br><br>
<dd>>>> e[2].tb_lineno<br><br>
<dd>2<br><br>
<dd>>>> e[2].tb_frame.f_code.co_filename<br><br>
<dd>'<stdin>'<br><br>
<dd> <br><br>
<dd>You can enable on 64-bit:<br><br>
<dd> <br><br>
<dd>import IronPython <br><br>
<dd>IronPython.Compiler.Options.TraceBackSupport = True<br><br>
<dd> <br><br>
<dd>From:</b>
<a href="mailto:users-bounces@lists.ironpython.com">
users-bounces@lists.ironpython.com
</a>[<a href="mailto:users-bounces@lists.ironpython.com" eudora="autourl">
mailto:users-bounces@lists.ironpython.com</a>] On Behalf Of </b>Matt
Beckius<br>
<dd>Sent:</b> Monday, August 21, 2006 7:18 AM<br>
<dd>To:</b>
<a href="mailto:users@lists.ironpython.com">users@lists.ironpython.com</a>
<br>
<dd>Subject:</b> [IronPython] Getting a line number of error (RC2)
<br><br>
<dd> <br><br>
<dd>Trying to get the line number of an error. CPython
produces:<br><br>
<dd> <br><br>
<dd>Python 2.4.2 (#67, Sep 28 2005, 12:41:11)<br>
<dd>Type "help", "copyright", "credits" or
"li<br>
<dd>>>> def test():<br>
<dd>... print "hi"<br>
<dd>... int("hi")<br>
<dd>...<br>
<dd>>>> test()<br>
<dd>hi<br>
<dd>Traceback (most recent call last):<br>
<dd> File "<stdin>", line 1, in ?<br>
<dd> File "<stdin>", line 3, in test<br>
<dd>ValueError: invalid literal for int(): hi<br><br>
<dd> <br><br>
<dd> <br><br>
<dd>But IP RC2 produces:<br><br>
<dd> <br><br>
<dd>IronPython 1.0.60816 on .NET 2.0.50727.42<br>
<dd>Copyright (c) Microsoft Corporation. All rights reserved.<br>
<dd>>>> def test():<br>
<dd>... print "hi"<br>
<dd>... int("hi")<br>
<dd>...<br>
<dd>>>> test() <br>
<dd>hi<br>
<dd>Traceback (most recent call last):<br>
<dd> File , line 0, in <stdin>##5<br>
<dd> File , line 0, in test<br>
<dd>ValueError: invalid integer number literal<br><br>
<dd> <br><br>
<dd>How do I get the line number of this runtime error? <br><br>
<dd> <br><br>
<dd>MattB
</dl></blockquote></body>
<br>
<br>
J. Merrill / Analytical Software Corp</html>