diff mercurial/windows.py @ 45148:a37f290a7124

windows: always work around EINVAL in case of broken pipe for stdout / stderr In 29a905fe23ae, I missed the fact that the `winstdout` class works around two unrelated bugs (size limit when writing to consoles and EINVAL in case of broken pipe) and that the latter bug happens even when no console is involved. When writing a test for this, I realized that the same problem applies to stderr, so I applied the workaround for EINVAL to both stdout and stderr. The size limit is worked around in the same case as before (consoles on Windows on Python 2). For that, I changed the `winstdout` class.
author Manuel Jacob <me@manueljacob.de>
date Fri, 17 Jul 2020 03:28:52 +0200
parents aea246bc04bd
children 74b486226480
line wrap: on
line diff
--- a/mercurial/windows.py	Fri Jul 17 00:37:33 2020 +0200
+++ b/mercurial/windows.py	Fri Jul 17 03:28:52 2020 +0200
@@ -197,6 +197,7 @@
 
     def __init__(self, fp):
         self.fp = fp
+        self.throttle = not pycompat.ispy3 and fp.isatty()
 
     def __getattr__(self, key):
         return getattr(self.fp, key)
@@ -208,13 +209,16 @@
             pass
 
     def write(self, s):
+        if not pycompat.ispy3:
+            self.softspace = 0
         try:
+            if not self.throttle:
+                return self.fp.write(s)
             # This is workaround for "Not enough space" error on
             # writing large size of data to console.
             limit = 16000
             l = len(s)
             start = 0
-            self.softspace = 0
             while start < l:
                 end = start + limit
                 self.fp.write(s[start:end])