[PATCH 6 of 7] py3: use try/except to check for basestring
Yuya Nishihara
yuya at tcha.org
Tue Nov 8 09:16:38 EST 2016
On Mon, 7 Nov 2016 20:37:14 +0530, Pulkit Goyal wrote:
> 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?
Can you pick out good ones?
FYI, the basestring patch had a problem, which didn't work on Python 2.
https://www.mercurial-scm.org/pipermail/mercurial-devel/2016-October/089160.html
More information about the Mercurial-devel
mailing list