On Sun, 09 Dec 2018 23:39:33 -0500, Matt Harbison wrote:
> I ended up with similar stdio errors trying to track down the bad http  
> status failures:
> 
> Traceback (most recent call last):
>    File "c:\Users\Matt\hg\mercurial\ui.py", line 1033, in _writenobuf
>      dest.flush()
> OSError: [WinError 1] Incorrect function
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):
>    File "c:\Users\Matt\hg\mercurial\hgweb\server.py", line 192, in do_hgweb
>      for chunk in self.server.application(env, self._start_response):
>    File "c:\Users\Matt\hg\mercurial\hgweb\hgweb_mod.py", line 310, in  
> run_wsgi
>      for r in self._runwsgi(req, res, repo):
>    File "c:\Users\Matt\hg\mercurial\hgweb\hgweb_mod.py", line 430, in  
> _runwsgi
>      return getattr(webcommands, cmd)(rctx)
>    File "c:\Users\Matt\hg\mercurial\hgweb\webcommands.py", line 861, in  
> comparison
>      context = parsecontext(web.config('web', 'comparisoncontext', '5'))
>    File "c:\Users\Matt\hg\mercurial\hgweb\hgweb_mod.py", line 117, in config
>      untrusted=untrusted)
>    File "c:\Users\Matt\hg\mercurial\ui.py", line 517, in config
>      untrusted=untrusted)
>    File "c:\Users\Matt\hg\mercurial\ui.py", line 536, in _config
>      self.develwarn(msg, 2, 'warn-config-unknown')
>    File "c:\Users\Matt\hg\mercurial\ui.py", line 1790, in develwarn
>      % (msg, fname, lineno, fmsg))
>    File "c:\Users\Matt\hg\mercurial\ui.py", line 996, in write_err
>      self._write(self._ferr, *args, **opts)
>    File "c:\Users\Matt\hg\mercurial\ui.py", line 1006, in _write
>      self._writenobuf(dest, *args, **opts)
>    File "c:\Users\Matt\hg\mercurial\ui.py", line 1039, in _writenobuf
>      raise error.StdioError(err)
> mercurial.error.StdioError: [Errno 22] Incorrect function
> 
> I see that there's a TODO for pycompat.{stdin,stdout,stderr} to use a  
> silly wrapper instead of .buffer.  But this feeble attempt didn't seem to  
> help:

That's unrelated issue. A pseudo file object might not have .buffer, but a
real stdio object should have one.

Perhaps, the underlying file descriptor would be messed up in Windows way.
If we can know that prior to calling write(), stdio fds can be reattached to
NUL. But I don't know if that's possible.

Another Py3 issue is that sys.stdin/stdout/stderr is None on pythonw.exe.
IIRC, this can be worked around by attaching NUL to fd=0-2, and open them.

  nullfd = os.open(os.devnull, O_RDWR | O_BINARY)
  os.dup2(nullfd, 0)
  os.dup2(nullfd, 1)
  os.dup2(nullfd, 2)
  os.close(nullfd)
  stdin = os.fdopen(0, 'rb')
  stdout = os.fdopen(1, 'wb')
  stderr = os.fdopen(2, 'wb')

But it might break ui.isatty() since NUL is reported as a tty on Windows.
_______________________________________________
Mercurial-devel mailing list
Mercurial-devel@mercurial-scm.org
https://www.mercurial-scm.org/mailman/listinfo/mercurial-devel

Reply via email to