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

Method run_on_interactive_mode

Lib/test/test_inspect/test_inspect.py:6609–6621  ·  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.

(self, source)

Source from the content-addressed store, hash-verified

6607 **kw)
6608
6609 def run_on_interactive_mode(self, source):
6610 """Spawn a new Python interpreter, pass the given
6611 input source code from the stdin and return the
6612 result back. If the interpreter exits non-zero, it
6613 raises a ValueError."""
6614
6615 process = self.spawn_repl()
6616 process.stdin.write(source)
6617 output = kill_python(process)
6618
6619 if process.returncode != 0:
6620 raise ValueError("Process didn't exit properly.")
6621 return output
6622
6623 @unittest.skipIf(not has_subprocess_support, "test requires subprocess")
6624 def test_getsource(self):

Callers 1

test_getsourceMethod · 0.95

Calls 3

spawn_replMethod · 0.95
kill_pythonFunction · 0.90
writeMethod · 0.45

Tested by

no test coverage detected