[PATCH 02 of 10] localrepo: bytes for errors

Jun Wu quark at fb.com
Fri May 13 09:59:45 EDT 2016


One possible solution doing the "" -> b"" conversion is to abuse the

   # coding:

comment and use codecs.register to support a dialect that replaces
all "" to b"" at compiling time.

Existing projects doing this:
1. https://github.com/dropbox/pyxl
2. https://github.com/syrusakbary/interpy


On 05/13/2016 04:48 AM, Gregory Szorc wrote:
 > On Wed, May 11, 2016 at 9:47 PM, Matt Mackall <mpm at selenic.com> wrote:
 >> Also, be aware that I'm going to have a very dim view of bulk "" -> b""
 >> patches.
 >> There are 100x more bare strings than xrange calls, and we've already been
 >> there.
 >>
 >
 > Unfortunately, we're going to need to mass convert "" to b"" if we wish to
 > run the same source on Python 2/3 otherwise Python 3 is going to assume
 > string literals are unicode, which is the exact opposite of what we want.
 > In theory, we might be able to implement a custom module loader on Python 3
 > that does source/ast translation when loading .py files. But this scares me
 > for several reasons.
 >
 > As for this series, I think mass converting "" to b"" is preferred to
 > converting whatever strings you happen to trip over when running whatever
 > tests are failing on Python 3. It's probably easiest to start with
 > everything as bytes and then introduce unicode/str type only where
 > necessary instead of going through this intermediate phase where half the
 > variables/types aren't compatible with Python 3.


More information about the Mercurial-devel mailing list