[Python-Dev] PEP460 thoughts from a Mercurial dev

Augie Fackler raf at durin42.com
Mon Jan 13 14:57:05 CET 2014


(sorry for not piling on any existing threads - I don't subscribe to
python-dev due to lack of time)

Brett Cannon asked me to chime in - I haven't actually read the very long
thread at this point, I'm just providing responses to things Brett
mentioned:

1) What do we need in terms of functionality

Best guess, %s, %d, and %f. I've not done a full audit of the code, but
some limited looking over the grep hits for % in .py files suggests I'm
right, and we could even do without %f (we only use that for 'hg --time'
output, which we could do in unicode).

We also need some way to emit raw bytes (in potentially mixed encodings,
yes I know this is "doing it wrong") to stdout/stderr (example: someone
changes a file from latin1 to utf8, and then wants to see the resulting
diff).

2) Would having it as an external library that worked with Python 2 help?

Probably, IF it came with 2.4 support (RHEL support, basically), and we
could bundle it in our source tree. It's been extremely valuable to have
the install only depend on a working C compiler and Python.

3) If this does go in, how long would it take us to port Mercurial to py3?
Would it being in 3.5 hold us up?

I'm honestly not sure. I'm still in the outermost layers of this yak shave:
fixing cyclic imports. I'll know more when I can at least get 'hg version'
to print its own version, because at that point the testsuite failures
might be informative. I'd honestly _rather_ this went into 3.5 *and* got
lots of validation by both us and twisted (the other folks that care?)
before becoming set in stone by a release. Does that make sense?

4) Do we care if it's .format()/%, or could it be in the stdlib?

It'd be really nice to not have to boil the oceans as far as editing
everyplace in the codebase that does % today. If we do have to do that,
it's not going to be much more helpful than something like:

def maybestr(a):
  if isinstance(a, bytes):
    return a.decode('latin1)
  return a

def sprintf(fmt, *args):
  (fmt.decode('latin1') % [maybestr(a) for a in args]).encode('latin1)

or similar. That was (roughly) what I was figuring I'd do today without any
formal bytes-string-formatting support.


He also mentioned that some are calling for a shortened 3.5 release cycle -
I'd rather not see that happen, for the aforementioned reason of wanting
time to make sure this is Right - it'd be a shame to do the work and rush
it out only to find something missing in an important way.

Feel free to ask further questions - I'll try to respond promptly.

AF

(For those curious: my hg-on-py3 repo isn't published at the moment because
I rebuilt the server it lived on and I forgot to publish it. I'll rectify
that sometime this week, I hope, but it's really totally nonfunctional due
to cyclic imports.)
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20140113/faabcc2f/attachment.html>


More information about the Python-Dev mailing list