Spawn a new Python interpreter, pass the given input source code from the stdin and return the result back. If the interpreter exits non-zero, it raises a ValueError.
(source)
| 68 | |
| 69 | |
| 70 | def run_on_interactive_mode(source): |
| 71 | """Spawn a new Python interpreter, pass the given |
| 72 | input source code from the stdin and return the |
| 73 | result back. If the interpreter exits non-zero, it |
| 74 | raises a ValueError.""" |
| 75 | |
| 76 | process = spawn_repl() |
| 77 | process.stdin.write(source) |
| 78 | output = kill_python(process) |
| 79 | |
| 80 | if process.returncode != 0: |
| 81 | raise ValueError("Process didn't exit properly.") |
| 82 | return output |
| 83 | |
| 84 | |
| 85 | @support.force_not_colorized_test_class |
no test coverage detected
searching dependent graphs…