title: PyRun_String stop sending result to stdout after any error
body: <p>I'm writing a Python terminal GUI in C++. I'm using the following code to run a user-typed Python command-line:</p>
  
  <pre><code>void RunTerminalCommand (char * line) 
  {
  
      PyObject *py_main, *py_dict;
      py_main = PyImport_AddModule("__main__");
      py_dict = PyModule_GetDict(py_main);
      PyObject * PyRes = PyRun_String(line, Py_single_input, py_dict, py_dict);
  
      return 0;
  }
  </code></pre>
  
  <p>It works very well, with the command line being executed and the result being printed on the output window via stdout. But whenever the Python command line leads to a Python error, it stops working: My stdout doesn't receive any data</p>
  
  <p>Notes:</p>
  
  <ul>
  <li><p>PyRes always returns NULL, even before the error line is injected</p></li>
  <li><p>I don't know if I should call PyImport_AddModule every time. But it seems to work this way.</p></li>
  <li><p>If I use <strong>PyRun_SimpleString(line)</strong> insted of <strong>PyRun_String(line, Py_single_input, py_dict, py_dict)</strong>, it always work, and I still get the Error messages via stdout/stderr. But this call doesn't send the result of command line evaluatiosn to stdout, so I don't want to use it. For example, the command line "2+2" will print "4" on stdout when I use PyRun_String, but not when I use PyRun_SimpleString. </p></li>
  </ul>