Topics

Are all these exceptions normal?

Wim van der Vegt
 

Hi

I'm new to ironPython and was wondering if all the exception i see when running small pieces of code are normal (it does not build confidence seeing so many)

1) 
python code:
                import sys
                def Simple():
                 print "Hello from Python"
                 print "Call Dir(): "
                 print dir()
                 print "Print the Path: " 
                 print sys.path

executed by:
                ScriptRuntime runtime = Python.CreateRuntime();
                dynamic ss = runtime.UseFile("Test.py");
                ss.Simple();

exception(s):
Exception thrown: 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' in Microsoft.CSharp.dll
2) 
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);

exceptions:
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

The original code which assigned the String.Format output to a variable and print it did not work at all (with the message the variable could not be found. So this code failed to execute at all.
                //"blurb = String.Format(\"{0} { 1}\", \"Hello World! The current date and time is \", DateTime.Now)\r\n" +
                //"print blurb\r\n";