From 2080abf0a3038be9875264139629858c1bd14b51 Mon Sep 17 00:00:00 2001 From: Jehan Date: Wed, 12 Oct 2022 23:40:04 +0200 Subject: [PATCH] Issue #8734: Python-fu misses sys.stdout.flush. Just add a no-op flush() as I think it's actually unneeded in the context of a GtkTextView GUI. At least it doesn't cause issues with copy-pasted code or when using external libraries using the sys.stdout.flush() interface. --- plug-ins/python/python-console/pyconsole.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plug-ins/python/python-console/pyconsole.py b/plug-ins/python/python-console/pyconsole.py index ab0ee2d306..c923e36248 100644 --- a/plug-ins/python/python-console/pyconsole.py +++ b/plug-ins/python/python-console/pyconsole.py @@ -80,6 +80,14 @@ class _ReadLine(object): def write(self, text): pos = self.buffer.get_iter_at_mark(self.buffer.get_insert()) self.buffer.insert_with_tags_by_name(pos, text, self.tag_name) + def flush(self): + # The output is just a GtkTextBuffer inside a GtkTexView so I + # believe it should be always in-sync without needing to be flushed. + # Nevertheless someone might be just copy-pasting plug-in code to + # test it, for instance. So let's just add a no-op flush() method to + # get a similar interface as the real sys.stdout which we overrode. + # It avoids useless and unexpected code failure. + pass class History(object): def __init__(self):