IronLanguages / main

Work for this repo has moved to https://github.com/IronLanguages/ironpython2
1.16k stars 347 forks source link

traceback.format_exc() not working #1659

Closed Lysander83 closed 7 years ago

Lysander83 commented 7 years ago

We have a .net 4 program that hosts IronPython engine. if an exception is raised while running the script then we cannot get the stack trace information by traceback.format_exc() It worked with IronPython 2.7.5 We cannot reproduce it by running IronPython 2.7 ipy.exe

slozier commented 7 years ago

I haven't been able to reproduce. Some more details would be helpful. I tried running the following and it worked fine:

var test = @"
import traceback
def test():
    raise Exception
try:
    test()
except Exception as e:
    print traceback.format_exc()
";
engine.CreateScriptSourceFromString(test).Execute();
Lysander83 commented 7 years ago

I do not what to say. I will try to make a simple app to reproduce it next week. Our IronPython engine uses py files. Maybe it is important. The traceback and other modules were imported from IP 2.7.7 in both cases the working and not working so the problem must be in IronPython.dll or other dll.

The working version generates the following output: Traceback (most recent call last): File "C:\temp...\SDTPanel.py", line 158, in _runPanelItemScript result=self._panelItemScriptMethod() File "", line 50, in VariableUpload File "C:\temp...\SDTTestSetup.py", line 42, in getitem raise KeyError, "..." KeyError: "..."

The not working version generates the first 2 lines plus 4 pieces of space character. Traceback (most recent call last): File "C:\temp...\SDTPanel.py", line 158, in _runPanelItemScript

Lysander83 commented 7 years ago

Sorry, I have never used github before. It is still open for me.

slide commented 7 years ago

This issue was moved to IronLanguages/ironpython2#35