[PATCH 5 of 5] check-code: handle py3 open divergence

timeless timeless at gmail.com
Mon May 16 15:12:39 EDT 2016


timeless <timeless at gmail.com> wrote:
> So, on the py2 side of things, io.open seems to like to return
> <unicode>, whereas our stuff expects <str>.
>
> On the py3 side of things. If I can avoid having to talk about unicode, I
> will.

Martijn Pieters <mj at zopatista.com> wrote:
> But you could use binary mode and have `bytes` on Python 3 and `str` on
> Python 2. The only disadvantage is that universal line ending translation is
> gone, so you get `\r\n` if that's the convention in a given file.

Doing that would require rewriting all the r'...' lines as br'...'.

At this point. I'd like to avoid doing that, since there's half a
chance that someone will write a module loader hack which will let us
skip that.

If we get that, then I'm happy to replace the opentext I've written w/
a py2+py3 io.open(...,'rb').


More information about the Mercurial-devel mailing list