From 3b451743753fc99d56e424d04f810c59acd33968 Mon Sep 17 00:00:00 2001 From: gatecat Date: Mon, 22 Feb 2021 10:48:21 +0000 Subject: [PATCH] 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 --- 3rdparty/python-console/modified/pyinterpreter.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/3rdparty/python-console/modified/pyinterpreter.cc b/3rdparty/python-console/modified/pyinterpreter.cc index c222c9ad..99b8883e 100644 --- a/3rdparty/python-console/modified/pyinterpreter.cc +++ b/3rdparty/python-console/modified/pyinterpreter.cc @@ -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");