Pyrun_string Stop Sending Result To Stdout After Any Error
Solution 1:
I've gone through a similar problem, and solved it by adding a "\n" (Carriage-return) using Py_Run_SimpleString right after the user command line, as in the example:
PyRun_String(line, Py_single_input, py_dict, py_dict);
PyRun_SimpleString("\n");
It doesn't work if you add the "\n" at the end of PyRun_String. It needs to be a separated call to PyRun_SimpleString
Solution 2:
First there's this in the documentation of PyImport_AddModule
:
First check the modules dictionary if there’s one there, and if not, create a new one and insert it in the modules dictionary. Return NULL with an exception set on failure.
You don't check that the module is already in the dictionary first.
In the documentation for PyRun_String
there's this:
Returns the result of executing the code as a Python object, or NULL if an exception was raised.
You don't ever check if it succeeded or not.
There's a few other things that are missing from your code. I think the main point is that you go and read the documentation and make sure you understand what it says and write the code required to check for error conditions, etc...
Post a Comment for "Pyrun_string Stop Sending Result To Stdout After Any Error"