Topics

[users] Are these Exceptions normal?

Alex Earl
 

Normally there will be more information in the stack trace, can you provide that?


On Mon, Nov 12, 2018 at 3:47 PM Wim van der Vegt <wim@...> wrote:

Hi

 

I’m new to IronPython and am wondering if the amount of exception I see are normal. Below two simple examples I tried. The number of exceptions does not build much confidence in IronPython.

 

1)      Python Code:
import sys

def Simple():

        print "Hello from Python"

        print "Call Dir(): "

        print dir()

        print "Print the Path: "

        print sys.path
C# code:
        ScriptRuntime runtime = Python.CreateRuntime();

        dynamic ss = runtime.UseFile("Test.py");

        ss.Simple();

Exception(s):

        Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in Microsoft.CSharp.dll

 

  1. Python/C# code:
                    String script =

                    "import sys;\r\n" +

                    "import clr\r\n" +

                    "clr.AddReference(\"System\")\r\n" +

                    "clr.AddReference(\"System.Core\")\r\n" +

                    "from System import DateTime, String;\r\n" +

                    "print String.Format(\"{0}\", \"Hello World!\")\r\n" +

                    "print \"Hello again from Python\"";

 

                ScriptEngine engine = Python.CreateEngine();

                ScriptScope scope = engine.CreateScope();

                ScriptSource source = engine.CreateScriptSourceFromString(script, SourceCodeKind.AutoDetect);

                CompiledCode compiled = source.Compile();

                dynamic result = compiled.Execute(scope);

Exception(s):
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in IronPython.Modules.dll

Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll

Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in Microsoft.Dynamic.dll

Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in Microsoft.Dynamic.dll

 

Wim van der Vegt
 

Hi

 

I do not get a stacktrace, the program seems to run, i just see quite some exceptions in the output window.

 

 

From: Alex Earl
Sent: dinsdag 13 november 2018 05:27
To: users@ironpython.groups.io
Subject: Re: [ironpython] [users] Are these Exceptions normal?

 

Normally there will be more information in the stack trace, can you provide that?

 

On Mon, Nov 12, 2018 at 3:47 PM Wim van der Vegt <wim@...> wrote:

Hi

 

I’m new to IronPython and am wondering if the amount of exception I see are normal. Below two simple examples I tried. The number of exceptions does not build much confidence in IronPython.

 

1)      Python Code:
import sys

def Simple():

        print "Hello from Python"

        print "Call Dir(): "

        print dir()

        print "Print the Path: "

        print sys.path
C# code:
        ScriptRuntime runtime = Python.CreateRuntime();

        dynamic ss = runtime.UseFile("Test.py");

        ss.Simple();

Exception(s):

        Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in Microsoft.CSharp.dll

 

  1. Python/C# code:
                    String script =

                    "import sys;\r\n" +

                    "import clr\r\n" +

                    "clr.AddReference(\"System\")\r\n" +

                    "clr.AddReference(\"System.Core\")\r\n" +

                    "from System import DateTime, String;\r\n" +

                    "print String.Format(\"{0}\", \"Hello World!\")\r\n" +

                    "print \"Hello again from Python\"";

 

                ScriptEngine engine = Python.CreateEngine();

                ScriptScope scope = engine.CreateScope();

                ScriptSource source = engine.CreateScriptSourceFromString(script, SourceCodeKind.AutoDetect);

                CompiledCode compiled = source.Compile();

                dynamic result = compiled.Execute(scope);

Exception(s):
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in IronPython.Modules.dll

Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll

Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in Microsoft.Dynamic.dll

Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in Microsoft.Dynamic.dll

 

 

Alex Earl
 

Yes, there will be exceptions during execution. 


On Tue, Nov 13, 2018 at 4:45 AM Wim van der Vegt <wim@...> wrote:

Hi

 

I do not get a stacktrace, the program seems to run, i just see quite some exceptions in the output window.

 

 

From: Alex Earl
Sent: dinsdag 13 november 2018 05:27
To: users@ironpython.groups.io
Subject: Re: [ironpython] [users] Are these Exceptions normal?

 

Normally there will be more information in the stack trace, can you provide that?

 

On Mon, Nov 12, 2018 at 3:47 PM Wim van der Vegt <wim@...> wrote:

Hi

 

I’m new to IronPython and am wondering if the amount of exception I see are normal. Below two simple examples I tried. The number of exceptions does not build much confidence in IronPython.

 

1)      Python Code:
import sys

def Simple():

        print "Hello from Python"

        print "Call Dir(): "

        print dir()

        print "Print the Path: "

        print sys.path
C# code:
        ScriptRuntime runtime = Python.CreateRuntime();

        dynamic ss = runtime.UseFile("Test.py");

        ss.Simple();

Exception(s):

        Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in Microsoft.CSharp.dll

 

  1. Python/C# code:
                    String script =

                    "import sys;\r\n" +

                    "import clr\r\n" +

                    "clr.AddReference(\"System\")\r\n" +

                    "clr.AddReference(\"System.Core\")\r\n" +

                    "from System import DateTime, String;\r\n" +

                    "print String.Format(\"{0}\", \"Hello World!\")\r\n" +

                    "print \"Hello again from Python\"";

 

                ScriptEngine engine = Python.CreateEngine();

                ScriptScope scope = engine.CreateScope();

                ScriptSource source = engine.CreateScriptSourceFromString(script, SourceCodeKind.AutoDetect);

                CompiledCode compiled = source.Compile();

                dynamic result = compiled.Execute(scope);

Exception(s):
Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll

Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in IronPython.Modules.dll

Exception thrown: 'System.Reflection.TargetInvocationException' in mscorlib.dll

Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in Microsoft.Dynamic.dll

Exception thrown: 'IronPython.Runtime.Exceptions.ImportException' in Microsoft.Dynamic.dll