<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">

<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<meta name=Generator content="Microsoft Word 12 (filtered medium)">
<style>
<!--
 /* Font Definitions */
 @font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Tahoma;
        panose-1:2 11 6 4 3 5 4 4 2 4;}
@font-face
        {font-family:"Segoe UI";
        panose-1:2 11 5 2 4 2 4 2 2 3;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
        {mso-style-builtin:yes;
        margin:0in;
        margin-bottom:.0001pt;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        mso-style-builtin:yes;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        mso-style-builtin:yes;
        color:purple;
        text-decoration:underline;}
p.MsoAcetate, li.MsoAcetate, div.MsoAcetate
        {mso-style-priority:99;
        mso-style-builtin:yes;
        mso-style-link:"Balloon Text Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:8.0pt;
        font-family:"Tahoma","sans-serif";}
span.gmailquote
        {mso-style-name:gmail_quote;}
span.e
        {mso-style-name:e;}
span.sg
        {mso-style-name:sg;}
span.EmailStyle20
        {mso-style-type:personal-reply;
        font-family:"Calibri","sans-serif";
        color:#1F497D;}
span.BalloonTextChar
        {mso-style-name:"Balloon Text Char";
        mso-style-priority:99;
        mso-style-link:"Balloon Text";
        font-family:"Tahoma","sans-serif";}
.MsoChpDefault
        {mso-style-type:export-only;}
@page Section1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.Section1
        {page:Section1;}
-->
</style>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]-->
</head>

<body lang=EN-US link=blue vlink=purple>

<div class=Section1>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>After looking into this a little more I&#8217;ve opened CodePlex
bug #2409 to track this.&nbsp; <a
href="http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&amp;WorkItemId=2409">http://www.codeplex.com/WorkItem/View.aspx?ProjectName=IronPython&amp;WorkItemId=2409</a><o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>The issue here is two-fold.&nbsp; The first is that dynamic
methods (which is what we generate under the covers for any code entered at the
console) don&#8217;t have a good debugging story.&nbsp; They have a great
production code story though (in that the GC will collect them).&nbsp; To make
tracebacks work consistently we currently track line number information during
code execution (when tracebacks are enabled).&nbsp; Unfortunately we&#8217;re
not using the line number information that we gather for the trace back to
display to the user, instead we just look at the debugging info that we expect to
be there for methods.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>To get the trace back info from C# code you&#8217;ll need to
call Ops.ExtractException(ex, pythonEngine.Sys);&nbsp; This will return back to
you the raw Python exception (an instance of an old-style class) and you&#8217;ll
be able to call pythonEngine.Sys.exc_info() after that to successfully get the
tuple.&nbsp; Then you should call Ops.ClearException(pythonEngine.Sys); when
you&#8217;re all done to remove the exception info from the current thread as
an exception is no longer in flight.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'>Let me know how well that work around works for you.&nbsp; If
that&#8217;s acceptable then it seems like we could leave this as a 1.01 bug.<o:p></o:p></span></p>

<p class=MsoNormal><span style='font-size:11.0pt;font-family:"Calibri","sans-serif";
color:#1F497D'><o:p>&nbsp;</o:p></span></p>

<div style='border:none;border-top:solid #B5C4DF 1.0pt;padding:3.0pt 0in 0in 0in'>

<p class=MsoNormal><b><span style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>From:</span></b><span
style='font-size:9.0pt;font-family:"Segoe UI","sans-serif"'>
users-bounces@lists.ironpython.com [mailto:users-bounces@lists.ironpython.com] <b>On
Behalf Of </b>Matt Beckius<br>
<b>Sent:</b> Tuesday, August 22, 2006 5:24 AM<br>
<b>To:</b> Discussion of IronPython<br>
<b>Subject:</b> Re: [IronPython] Getting a line number of error (RC2)<o:p></o:p></span></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

<div>

<p class=MsoNormal>Well, I guess since CPython does provide it, I would expect
IronPython to.&nbsp; More importantly, I am embedding IronPython in a hosting
app, and I'm trying to accurately report where errors occur.&nbsp; When an
error occurs due to something like I previously outlined, only
a&nbsp;ArgumentException is raised (I don't get a line number),&nbsp; I tried
adapting Dino's example by calling pythonEnging.Sys.exc_inf(), but the tuple's
3 memebers are null.<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>TIA,<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>MattB<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span style='font-size:10.0pt;color:teal'>&nbsp;</span><o:p></o:p></p>

</div>

<div>

<p class=MsoNormal>&nbsp;<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><span class=gmailquote>On 8/21/06, <b>J. Merrill</b> &lt;<a
href="mailto:jvm_cop@spamcop.net">jvm_cop@spamcop.net</a>&gt; wrote:</span> <o:p></o:p></p>

<div>

<div>

<p class=MsoNormal>You can get the line number info by using Dino's code
(calling sys.exc_info).&nbsp; 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<o:p></o:p></p>

</div>

<div>

<p class=MsoNormal><br>
<br>
<span class=e><o:p></o:p></span></p>

<p class=MsoNormal style='margin-bottom:12.0pt'>No 32bit.&nbsp; I tried
manually setting the TraceBackSupport, but still got the same result:<br>
&nbsp;<br>
IronPython 1.0.60816 on .NET 2.0.50727.42<br>
Copyright (c) Microsoft Corporation. All rights reserved. <br>
&gt;&gt;&gt; import IronPython<br>
&gt;&gt;&gt;<br>
&gt;&gt;&gt; IronPython.Compiler.Options.TraceBackSupport = True <br>
&gt;&gt;&gt; def Test():<br>
...&nbsp;&nbsp;&nbsp;&nbsp; print &quot;test&quot;<br>
...&nbsp;&nbsp;&nbsp;&nbsp; int(&quot;test&quot;)<br>
... <br>
&gt;&gt;&gt; Test()<br>
test<br>
Traceback (most recent call last):<br>
&nbsp; File , line 0, in &lt;stdin&gt;##12<br>
&nbsp; File , line 0, in Test <br>
ValueError: invalid integer number literal<br>
&gt;&gt;&gt;<br>
<br>
&nbsp;<br>
On 8/21/06, <b>Dino Viehland</b> &lt;<a
href="mailto:dinov@exchange.microsoft.com" target="_blank">
dinov@exchange.microsoft.com</a>&gt; wrote: <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>Are you running on a 64-bit machine w/ a 64-bit
runtime?&nbsp; 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. <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>If I do:<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>import sys<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>def test2():<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;&nbsp;&nbsp; try: test()<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;&nbsp;&nbsp; except ValueError, ex:<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; global e<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; import sys<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; e =
sys.exc_info()<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>test2()<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>e<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&gt;&gt;&gt; e[2].tb_lineno<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>2<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&gt;&gt;&gt; e[2].tb_frame.f_code.co_filename<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>'&lt;stdin&gt;'<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>You can enable on 64-bit:<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>import IronPython <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>IronPython.Compiler.Options.TraceBackSupport = True<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>From: <a
href="mailto:users-bounces@lists.ironpython.com" target="_blank">users-bounces@lists.ironpython.com
</a>[<a href="mailto:users-bounces@lists.ironpython.com" target="_blank">
mailto:users-bounces@lists.ironpython.com</a>] On Behalf Of Matt Beckius<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>Sent: Monday, August 21, 2006 7:18
AM<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>To: <a
href="mailto:users@lists.ironpython.com" target="_blank">users@lists.ironpython.com</a>
<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>Subject: [IronPython] Getting a line number of error
(RC2) <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>Trying to get the line number of an error.&nbsp;
CPython produces:<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>Python 2.4.2 (#67, Sep 28 2005,
12:41:11)<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>Type &quot;help&quot;,
&quot;copyright&quot;, &quot;credits&quot; or &quot;li<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>&gt;&gt;&gt; def test():<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>...&nbsp;&nbsp;&nbsp;&nbsp; print
&quot;hi&quot;<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>...&nbsp;&nbsp;&nbsp;&nbsp;
int(&quot;hi&quot;)<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>...<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>&gt;&gt;&gt; test()<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>hi<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>Traceback (most recent call last):<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; File
&quot;&lt;stdin&gt;&quot;, line 1, in ?<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; File
&quot;&lt;stdin&gt;&quot;, line 3, in test<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>ValueError: invalid literal for int(): hi<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>But IP RC2 produces:<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>IronPython 1.0.60816 on .NET
2.0.50727.42<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>Copyright (c) Microsoft
Corporation. All rights reserved.<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>&gt;&gt;&gt; def test():<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>...&nbsp;&nbsp;&nbsp;&nbsp; print
&quot;hi&quot;<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>...&nbsp;&nbsp;&nbsp;&nbsp;
int(&quot;hi&quot;)<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>...<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>&gt;&gt;&gt; test() <o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>hi<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>Traceback (most recent call last):<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; File , line 0, in
&lt;stdin&gt;##5<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>&nbsp; File , line 0, in test<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>ValueError: invalid integer number literal<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>How do I get the line number of this runtime
error?&nbsp; <o:p></o:p></p>

<p class=MsoNormal style='mso-margin-top-alt:0in;margin-right:0in;margin-bottom:
12.0pt;margin-left:.5in'>&nbsp;<o:p></o:p></p>

<p class=MsoNormal style='margin-left:.5in'>MattB <o:p></o:p></p>

</div>

</div>

<div>

<p class=MsoNormal><br>
<br>
<span class=sg>J. Merrill / Analytical Software Corp </span><o:p></o:p></p>

</div>

<p class=MsoNormal style='margin-bottom:12.0pt'><br>
_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.ironpython.com">users@lists.ironpython.com</a><br>
<a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com"
target="_blank">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com </a><br>
<br>
<o:p></o:p></p>

</div>

<p class=MsoNormal><o:p>&nbsp;</o:p></p>

</div>

</body>

</html>