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

login
register
mail settings
Submitter Yuya Nishihara
Date June 5, 2017, 3:23 p.m.
Message ID <53953046e8e443c31fbe.1496676209@mimosa>
Download mbox | patch
Permalink /patch/21208/
State Accepted
Headers show

Comments

Yuya Nishihara - June 5, 2017, 3:23 p.m.
# HG changeset patch
# User Yuya Nishihara <yuya@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.

Patch

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():