[gimp] Issue #248: Python console doesn't support input()/raw_input().
- From: Jehan <jehanp src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gimp] Issue #248: Python console doesn't support input()/raw_input().
- Date: Fri, 15 Jun 2018 16:46:34 +0000 (UTC)
commit 79d55e09e439cc7be3bcbc2f6e093470c9a2f015
Author: Jehan <jehan girinstud io>
Date: Fri Jun 15 18:34:57 2018 +0200
Issue #248: Python console doesn't support input()/raw_input().
As noted by Massimo, we can just make the argument of raw_input() an
optional argument.
Also adding a modal implementation for input() so that it doesn't lock
the Python console waiting from input from the plug-in stdin. As noted
in Python doc, input() is equivalent to `eval(raw_input(prompt))`.
Not all that safe, but in the end, it is the developer's responsibility.
(cherry picked from commit 130ef5ce59a701344da79a224cc84495ab218df9)
Note: it is untested on master since we don't have Python right now, but
I don't see why it would not work here as well!
plug-ins/pygimp/plug-ins/pyconsole.py | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/plug-ins/pygimp/plug-ins/pyconsole.py b/plug-ins/pygimp/plug-ins/pyconsole.py
index 0f169961c7..05df576b8b 100644
--- a/plug-ins/pygimp/plug-ins/pyconsole.py
+++ b/plug-ins/pygimp/plug-ins/pyconsole.py
@@ -192,6 +192,9 @@ class _ReadLine(object):
return self.modal_raw_input_result
+ def modal_input(self, text):
+ return eval(self.modal_raw_input(text))
+
# Each time the insert mark is modified, move the cursor to it.
def on_buf_mark_set(self, buffer, iter, mark):
if mark is not buffer.get_insert():
@@ -522,7 +525,8 @@ class _Console(_ReadLine, code.InteractiveInterpreter):
# this. Therefore, replace this function with our own modal raw
# input function.
exec "import __builtin__" in self.locals
- self.locals['__builtin__'].__dict__['raw_input'] = lambda text: self.modal_raw_input(text)
+ self.locals['__builtin__'].__dict__['raw_input'] = lambda text='': self.modal_raw_input(text)
+ self.locals['__builtin__'].__dict__['input'] = lambda text='': self.modal_input(text)
self.start_script = start_script
self.completer = completer
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]