[PATCH 2 of 3] windows: do not close stdout on flush() failure

Yuya Nishihara yuya at tcha.org
Mon Jun 5 11:23:29 EDT 2017


# HG changeset patch
# User Yuya Nishihara <yuya at tcha.org>
# Date 1496673395 -32400
#      Mon Jun 05 23:36:35 2017 +0900
# Node ID 53953046e8e443c31fbe1a9b94e8b95e92f6bda6
# Parent  b3249cb334af076bf9787ac16ff92a2bb8e8567e
windows: do not close stdout on flush() failure

It's been there since e817c68edfed (2007-02-19), but seems wrong since any
I/O operations to a closed file would raise ValueError, not IOError. We should
keep the file object open even if the underlying file descriptor is half dead.

diff --git a/mercurial/windows.py b/mercurial/windows.py
--- a/mercurial/windows.py
+++ b/mercurial/windows.py
@@ -180,7 +180,6 @@ class winstdout(object):
         except IOError as inst:
             if inst.errno != errno.EINVAL:
                 raise
-            self.close()
             raise IOError(errno.EPIPE, 'Broken pipe')
 
 def _is_win_9x():


More information about the Mercurial-devel mailing list