[PATCH 6 of 7] py3: use try/except to check for basestring

Pulkit Goyal 7895pulkit at gmail.com
Mon Nov 7 10:07:14 EST 2016


On Mon, Nov 7, 2016 at 5:55 PM, Yuya Nishihara <yuya at tcha.org> wrote:
> On Mon, 7 Nov 2016 00:15:21 +0530, Pulkit Goyal wrote:
>> This https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/089099.html
>> is a better version of what I want to do, since this didn't went
>> through I will be using this.
>
> I'm okay with that pycompat.basestring stuff, but I'm pretty sure most of
> our basestring uses are moot since we avoid using unicodes except for very
> specific string manipulations.
>
>> >> @@ -520,7 +520,12 @@
>> >>          result = self.config(section, name, untrusted=untrusted)
>> >>          if result is None:
>> >>              result = default or []
>> >> -        if isinstance(result, basestring):
>> >> +        checkunicode = False
>> >> +        try:
>> >> +            checkunicode = isinstance(result, basestring)
>> >> +        except NameError:
>> >> +            checkunicode = isinstance(result, str)
>> >> +        if checkunicode:
>> >>              result = _configlist(result.lstrip(' ,\n'))
>
> And with this change, ui.configlist() would look as if it supports unicodes,
> which seems confusing.
Can you cherry pick some commits from that series?


More information about the Mercurial-devel mailing list