[PATCH 4 of 5] py3: stop subscripting socket.error

Yuya Nishihara yuya at tcha.org
Sun Dec 16 01:27:49 EST 2018


On Sun, 16 Dec 2018 01:19:47 -0500, Matt Harbison wrote:
> On Sun, 16 Dec 2018 00:55:20 -0500, Yuya Nishihara <yuya at tcha.org> wrote:
> 
> > On Sun, 16 Dec 2018 00:36:45 -0500, Matt Harbison wrote:
> >> > I'm not sure what to do with this info yet, but I just noticed that
> >> > pager is also messed up on py3- the debug message about spawning the
> >> > pager prints, but no output for the diff.  Use --pager=no, and it  
> >> shows
> >> > up.  So maybe there's a general problem with stdio of spawned  
> >> children.
> >>
> >> To be specific, this:
> >>
> >> diff --git a/mercurial/ui.py b/mercurial/ui.py
> >> --- a/mercurial/ui.py
> >> +++ b/mercurial/ui.py
> >> @@ -1206,6 +1207,14 @@ class ui(object):
> >>               pager.stdin.close()
> >>               pager.wait()
> >>
> >> +        try:
> >> +           self.write('test output\n')
> >> +           self.flush()
> >> +        except Exception:
> >> +            killpager()
> >> +            self.traceback(force=True)
> >> +            raise
> >> +
> >>           return True
> >>
> >>       @property
> >>
> >>
> >> Results in this:
> >>
> >> $ py -3 ../hg diff -r .^^ --debug
> >> *** failed to import extension evolve: No module named 'evolve'
> >> obsolete feature not enabled but 177518 markers found!
> >> starting pager for command 'diff'
> >>
> >> Traceback (most recent call last):
> >>    File "c:\Users\Matt\hg\mercurial\ui.py", line 1024, in _writenobuf
> >>      color.win32print(self, dest.write, msg, **opts)
> >>    File "c:\Users\Matt\hg\mercurial\color.py", line 528, in win32print
> >>      writefunc(m.group(2))
> >>    File "c:\Users\Matt\hg\mercurial\windows.py", line 202, in write
> >>      self.fp.write(s[start:end])
> >> OSError: [WinError 1] Incorrect function
> >
> > That might be because the stdio files are backed by the Windows-ish type.
> > Can you try PYTHONLEGACYWINDOWSSTDIO=1?
> >
> > https://www.python.org/dev/peps/pep-0528/
> >
> > Python 3 shifted away from being Unix scripting language in many ways.
> 
> Yep, that fixed both pager and the strange server problems, thanks.  I  
> need more sleep before digesting that PEP, but skimming it seems to imply  
> that we need to explicitly encode to stdio on Windows?  How will that  
> interact with the existing encoding functions?

I don't think we'll need the new Windows wrapper to get the Py2-level
Windows support. Instead, we'll have to make our exewrapper enable all
the "Legacy" options.

https://docs.python.org/3/c-api/init.html#global-configuration-variables


More information about the Mercurial-devel mailing list