[PATCH] stdout raises EINVAL when flush() is called on a closed pipe under win32

Patrick Mezard pmezard at gmail.com
Mon Feb 19 03:33:15 CST 2007


# HG changeset patch
# User Patrick Mezard <pmezard at gmail.com>
# Date 1171877566 -3600
# Node ID a092c5d2f2d9f2cb7d2dbcf37d712cc535959a46
# Parent  cc3c783b0030ee1275476973c97c49a81c1d1c13
stdout raises EINVAL when flush() is called on a closed pipe under win32.

Maybe the exception should be caught and translated at raise location instead (sshserver.py).

diff -r cc3c783b0030 -r a092c5d2f2d9 mercurial/util.py
--- a/mercurial/util.py	Mon Feb 19 10:29:05 2007 +0100
+++ b/mercurial/util.py	Mon Feb 19 10:32:46 2007 +0100
@@ -790,6 +790,14 @@ if os.name == 'nt':
                 if inst.errno != 0: raise
                 self.close()
                 raise IOError(errno.EPIPE, 'Broken pipe')
+                
+        def flush(self):
+            try:
+                return self.fp.flush()
+            except IOError, inst:
+                if inst.errno != errno.EINVAL: raise
+                self.close()
+                raise IOError(errno.EPIPE, 'Broken pipe')
 
     sys.stdout = winstdout(sys.stdout)
 


More information about the Mercurial-devel mailing list