[PATCH 2 of 2] py3: convert unicode paths given for hgweb config

Yuya Nishihara yuya at tcha.org
Tue Apr 23 19:22:20 EDT 2019

On Tue, 23 Apr 2019 11:20:05 -0400, Ludovic Chabant wrote:
> > > If we want to be consistent with other things like the hgclient API,
> > > maybe we shouldn't be nice and encode the string for the caller, and
> > > instead reject anything that's not bytes?
> > 
> > Sounds good to reject unicodes explicitly.
> I had sent a v2 of my patch with a better way to encode the string, but now that I'm checking the hgclient code I don't think it explicitly rejects unicode strings? I think it just dies very quickly as soon as it tries to concatenate a string and a bytes.

True, but I think it's good idea to provide a better error indication at
commonly-used API boundary so long as the cost doesn't matter.

> Is there some other precedent for rejecting arguments explicitly? Is it just about raising some ValueError exception?

You can raise error.ProgrammingError. templatefilters.json() has an example.

More information about the Mercurial-devel mailing list