[PATCH] win32mbcs: add reversing wrapper for some unicode-incompatible functions

FUJIWARA Katsunori foozy at lares.dti.ne.jp
Sun Sep 30 09:20:59 CDT 2012


At Sun, 30 Sep 2012 01:09:33 +0900,
FUJIWARA Katsunori wrote:
> 
> 
> This patch should be posted as STABLE, because adding fast-path for
> ASCII lowercase/uppercase in encoding.py (3745ae495ce5 and
> 9fb8312dbdbd) makes win32mbcs unavailable since 2.3: now, win32mbcs
> users should use Mercurial earlier than it.
> 
> But I found that this patch breaks some tests (test-check-code-hg.t
> and test-check-pyflakes.t), and is not complete to fix problems.

Oops, sorry for that I was confused with direct referring from util to
encoding.lower/upper in old version (eliminated by 0cb55b5c19a3),

Implementation of this patch itself seems to be enough to fix problem.

Checking code fails for:

> > > -def wrapper(func, args, kwds):
> > > -    # check argument is unicode, then call original
> > > -    for arg in args:
> > > -        if isinstance(arg, unicode):
> > > -            return func(*args, **kwds)
> > > -
> > > -    try:
> > > -        # convert arguments to unicode, call func, then convert back
> > > -        return encode(func(*decode(args), **decode(kwds)))
> > > -    except UnicodeError:
> > > -        raise util.Abort(_("[win32mbcs] filename conversion failed with"
> > > -                         " %s encoding\n") % (_encoding))
> > > -
> > > +def makewrapper(argconv, retconv, type):
> > > +    def wrapper(func, args, kwds):
> > > +        # check argument is unicode, then call original
> > > +        ret = None

this useless "ret = None" assignment, and:

> > > +        for arg in args:
> > > +            if isinstance(arg, type):
> > > +                return func(*args, **kwds)
> > > +        try:
> > > +            return retconv(func(*argconv(args), **argconv(kwds)))
> > > +        except UnicodeError:
> > > +            raise util.Abort(_("[win32mbcs] filename conversion failed with"
> > > +                               " %s encoding\n") % (_encoding))
> > > +    return wrapper
> > > +        
        ^^^^^^^
tailing whitespaces in the line above.

----------------------------------------------------------------------
[FUJIWARA Katsunori]                             foozy at lares.dti.ne.jp


More information about the Mercurial-devel mailing list