PythonInterpreter: don't add submitted command to history until it has been successfuly submitted (also stip trailing endline)