Commit 4196d003 authored by Romain Casati's avatar Romain Casati
Browse files

Python 3: use persistent stream redirection.

parent 85ff3106
......@@ -93,6 +93,17 @@ class InteractiveConsole(_pyodide_console.PyodideConsole):
self.execution_count = None
kwargs['globals'] = kwargs.get('globals', sys.modules['__main__'].__dict__)
kwargs['filename'] = kwargs.get('filename', "<input>")
kwargs['persistent_stream_redirection'] = True
# setup persistent stream redirection
def stdout_callback(text):
return self._stdout_callback(text)
kwargs['stdout_callback'] = stdout_callback
def stderr_callback(text):
return self._stderr_callback(text)
kwargs['stderr_callback'] = stderr_callback
super().__init__(*args, **kwargs)
self.locals = self.globals
self.start()
......@@ -185,8 +196,8 @@ class InteractiveConsole(_pyodide_console.PyodideConsole):
"""
self.locals['__eval_data__'] = data.to_py()
self.execution_count += 1
self.stdout_callback = stdout_callback
self.stderr_callback = stderr_callback
self._stdout_callback = stdout_callback
self._stderr_callback = stderr_callback
self.roll_in_history(code)
......
......@@ -24,7 +24,7 @@ importlib.invalidate_caches()
# interpretation system is the Pyodide's interactive console
_console = InteractiveConsole(persistent_stream_redirection=False)
_console = InteractiveConsole()
def locals():
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment