[meld/windows-font-fixes] bin/meld: More generic handling of sys.stdout absence



commit 3d87bae448c9bf98adec7df1af32fbba0aa6bcbf
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Sat May 23 10:36:38 2020 +1000

    bin/meld: More generic handling of sys.stdout absence
    
    The specific executable checking is fine, but the hope here is that we
    might, in some situations, be able to get console output that we are
    otherwise over-eager in disabling.

 bin/meld | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
---
diff --git a/bin/meld b/bin/meld
index 1c769000..3cb8eec4 100755
--- a/bin/meld
+++ b/bin/meld
@@ -32,7 +32,11 @@ from multiprocessing import freeze_support
 # Regarding pythonw.exe stdout, see also http://bugs.python.org/issue706263
 # Also cx_Freeze built with Win32GUI base sets sys.stdout to None
 # leading to exceptions in print() and freeze_support() that uses flush()
-if sys.executable.endswith("pythonw.exe") or sys.stdout is None:
+
+try:
+    sys.stdout.write("\n")
+    sys.stdout.flush()
+except IOError:
     devnull = open(os.devnull, "w")
     sys.stdout = sys.stderr = devnull
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]