MCPcopy Index your code
hub / github.com/python/cpython / run_on_interactive_mode

Function run_on_interactive_mode

Lib/test/test_repl.py:70–82  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

68
69
70def 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

Calls 3

kill_pythonFunction · 0.90
spawn_replFunction · 0.85
writeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…