FYI, if you are getting a NameError using RunString that usually means that the string you run needs to do some imports remember that RunString creates (essentially) a totally new global local namespace, so you¹ll need to import any names you need in your code snippet. e.g. CLR.Food.SpamAndEggs.cook() ...will fail but import CLR import CLR.Food CLR.Food.SpamAndEggs.cook() ...should work hope this helps, -Brian On 3/4/07 4:37 AM, "Seshagiri Cherukuri" <seshagiri.cherukuri@gmail.com> wrote:
hi All,
I have embedded pythonnet into my C# application and this works great as far as creating .net objects from python, executing methods etc. Here I am using the RunSimpleString (the PyRun_SimpleString) wrapper to send commands from the C# application to the pythonnet.
However I am facing the following problems:
1. After RunSimpleString, PyErr_Occurred or PyErr_Fetch are not able to detect any exceptions even if they did occur - for example, consider the code - curErr = PythonEngine.RunSimpleString("10/0\n" ); - this code does return a -1 value indicating error. - however after this none of PyErr_Occurred or PyErr_Fetch do not detect this error - from python documentation it looks like there is no way to obtain the exception information
2. using RunString - because of above problem I want to send a multi-line code including a try-except: block - I have tried using RunString with all the three modes - Py_eval_input, Py_single_input and Py_file_input - The RunString works only if the code does not have any .net objects or does not include any .net exceptions - If the code sent to RunString includes a .net object e.g. obj, then RunString always returns in NameError, obj is not defined
3. Strangely, if I run the console application, it is able to work with .net exceptions - both .net and user defined exceptions
4. Is this because of the new dictionary created while in RunString?
thanks
Sesh Cherukuri
_________________________________________________ Python.NET mailing list - PythonDotNet@python.org http://mail.python.org/mailman/listinfo/pythondotnet