pyconsole: Avoid lockup when reading from stdin

Create an empty temporary file for stdin; so reads fail rather than
locking up (otherwise doing help() would be enough to completely lock up
the GUI).

Signed-off-by: gatecat <gatecat@ds0.me>
This commit is contained in:
gatecat 2021-02-22 10:48:21 +00:00
parent c0a7cff304
commit 3b45174375

View File

@ -133,8 +133,10 @@ void pyinterpreter_initialize()
PyRun_SimpleString("import sys\n"
"import redirector\n"
"import tempfile\n"
"sys.path.insert(0, \".\")\n" // add current path
"sys.stdout = redirector.redirector()\n"
"sys.stdin = tempfile.TemporaryFile(mode='r')\n"
"sys.stderr = sys.stdout\n"
"import rlcompleter\n"
"sys.completer = rlcompleter.Completer()\n");