Mercurial > public > mercurial-scm > hg-stable
diff mercurial/windows.py @ 37882:3a0f322af192 stable
windows: fix incorrect detection of broken pipe when writing to pager
Paging e.g. hg incoming on Windows and quitting the pager before the
output is consumed will print 'abort: Invalid argument'. This is
because the windows error 0xE8 (ERROR_NO_DATA) is mapped to EINVAL
even though it is documented as 'The pipe is being closed'.
Note that this fix assumes that Windows' last error code is still
valid in the exception handler. It works correctly in all my tests.
A simpler fix would be to just map EINVAL to EPIPE, like was done is
flush previously, but that would be less precise.
This error was not observed previously, when pager was an extension.
author | Sune Foldager <cryo@cyanite.org> |
---|---|
date | Wed, 04 Jul 2018 14:19:13 +0200 |
parents | a6c6b7beb025 |
children | af8d8513d7de |
line wrap: on
line diff
--- a/mercurial/windows.py Tue Jul 03 12:10:22 2018 -0400 +++ b/mercurial/windows.py Wed Jul 04 14:19:13 2018 +0200 @@ -172,7 +172,7 @@ self.fp.write(s[start:end]) start = end except IOError as inst: - if inst.errno != 0: + if inst.errno != 0 and not win32.lasterrorwaspipeerror(inst): raise self.close() raise IOError(errno.EPIPE, 'Broken pipe') @@ -181,7 +181,7 @@ try: return self.fp.flush() except IOError as inst: - if inst.errno != errno.EINVAL: + if not win32.lasterrorwaspipeerror(inst): raise raise IOError(errno.EPIPE, 'Broken pipe')