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

Brett Cannon bcannon at gmail.com
Fri Mar 6 11:54:16 CST 2015


On Fri, Mar 6, 2015 at 12:28 PM Matt Mackall <mpm at selenic.com> wrote:

> 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.
>

OK, that should be easy enough to do. I'll send the patches individually as
I work through the patchbomb workflow. Plus it makes sure that I don't
accidentally break compatibility at any single point with Python 2 and
basically work up to Python 3 support.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://selenic.com/pipermail/mercurial-devel/attachments/20150306/b6ba63a2/attachment.html>


More information about the Mercurial-devel mailing list