Would you expect bytes or unicode (or both) for the hglib API in Python 3?

Matt Mackall mpm at selenic.com
Fri Mar 6 11:28:05 CST 2015


On Fri, 2015-03-06 at 13:57 +0000, Brett Cannon wrote:
> On Thu, Mar 5, 2015 at 6:55 PM Matt Mackall <mpm at selenic.com> wrote:
> 
> > On Thu, 2015-03-05 at 22:58 +0000, Brett Cannon wrote:
> > > On Tue, Jan 27, 2015 at 6:19 PM Matt Mackall <mpm at selenic.com> wrote:
> > >
> > > > On Tue, 2015-01-27 at 17:49 -0500, Brett Cannon wrote:
> > > > > I have a need to query Mercurial repositories for some log data and I
> > > > want
> > > > > to do it from Python 3. I would like to use hglib but it currently
> > > > doesn't
> > > > > support past Python 2.7. I'm willing to try and port it so it can
> > > > (somehow)
> > > > > support Python 2.4 - Python 3.4, but before I do that I would like to
> > > > know
> > > > > two things: 1) would you accept a porting of the library to Python 3
> > if
> > > > it
> > > > > can still support Python 2.4 (although obviously my life would be
> > easier
> > > > if
> > > > > Python 2.6 was the cut-off =), and 2) what kind of Python 3 API
> > would you
> > > > > want the library to have?
> > > >
> > > > Thanks for looking into this!
> > > >
> > > > For (1), yes, but I'd also consider a second branch in the repo if that
> > > > proved impossible. I wouldn't bother supporting 3.x < 3.4 though.
> > > >
> > >
> > > So I have a patched repository that has hglib working from Python 2.4 -
> > > 3.4. Considering it required touching every string literal in hglib it
> > > isn't a small change. But doing it piecemeal didn't work out either as
> > the
> > > test suite typically executes multiple commands in a single test file so
> > it
> > > wasn't exactly isolated work. Luckily it isn't a complicated set of
> > changes
> > > either.
> > >
> > > So how should I send this change in? Single patch? Single patch for the
> > > library code, separate patch for all the tests? I can't send the changes
> > > as-is since I didn't follow your commit message format for anything.
> >
> > If you publish your repo somewhere, I can give you some initial thoughts
> > about how to break it up.
> >
> 
> Done: https://bitbucket.org/brettcannon/hglib

Ok, I think your first few patches should be:

1) introduce util.b()
2) mechanical conversion to b() everywhere
3) introduce util.BytesIO
4) replace users of StringIO

,,which should make subsequent steps easier to read.

-- 
Mathematics is the supreme nostalgia of our time.




More information about the Mercurial-devel mailing list