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

Augie Fackler raf at durin42.com
Wed Jan 28 10:26:52 CST 2015


On Tue, Jan 27, 2015 at 03:03:59PM -0800, Sean Farley wrote:
>
> Brett Cannon writes:
>
> > 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?
> >
> > For 2) what I'm specifically wondering about is whether the API should be
> > returning bytes, Unicode strings, or should it depend on which method is
> > called in hglib.client.hgclient? E.g., should everything stored in an
> > hglib.client.revision instance be bytes or Unicode? How about other methods
> > like hglient.annotate()? And if it's Unicode strings should I always decode
> > based on what hgclient.encoding() returns or is there some other encoding I
> > should be using?
> >
> > I currently have all tests from test-annotate to test-move passing already
> > by returning Unicode strings and assuming UTF-8 encoding (mostly just so I
> > could see how hard the port would be), but I thought I should ask my two
> > questions before going any farther and then contemplating tidying up the
> > changes and seeing if they could be made backwards-compatible and thus
> > upstreamed.
>
> This is a can of worms. For starters, see the progress and reasoning so
> far:
>
> http://mercurial.selenic.com/wiki/SupportedPythonVersions#Python_3.x_support

Note that he's looking at hglib, not hg itself. This should be quite doable.

> _______________________________________________
> Mercurial-devel mailing list
> Mercurial-devel at selenic.com
> http://selenic.com/mailman/listinfo/mercurial-devel


More information about the Mercurial-devel mailing list