diff --git a/mercurial/peer.py b/mercurial/peer.py --- a/mercurial/peer.py +++ b/mercurial/peer.py @@ -10,6 +10,7 @@ from . import ( error, + pycompat, util, ) @@ -90,7 +91,7 @@ if not encresref: return encargsorres # a local result in this case self = args[0] - encresref.set(self._submitone(f.func_name, encargsorres)) + encresref.set(self._submitone(pycompat.funcname(f), encargsorres)) return next(batchable) setattr(plain, 'batchable', f) return plain diff --git a/mercurial/pycompat.py b/mercurial/pycompat.py --- a/mercurial/pycompat.py +++ b/mercurial/pycompat.py @@ -71,6 +71,9 @@ stdout = sys.stdout.buffer stderr = sys.stderr.buffer + def funcname(func): + return sysbytes(func.__name__) + # Since Python 3 converts argv to wchar_t type by Py_DecodeLocale() on Unix, # we can use os.fsencode() to get back bytes argv. # @@ -305,6 +308,10 @@ stdin = sys.stdin stdout = sys.stdout stderr = sys.stderr + + def funcname(func): + return func.func_name + if getattr(sys, 'argv', None) is not None: sysargv = sys.argv sysplatform = sys.platform diff --git a/mercurial/templater.py b/mercurial/templater.py --- a/mercurial/templater.py +++ b/mercurial/templater.py @@ -412,9 +412,10 @@ sym = findsymbolicname(arg) if sym: msg = (_("template filter '%s' is not compatible with keyword '%s'") - % (filt.func_name, sym)) + % (pycompat.funcname(filt), sym)) else: - msg = _("incompatible use of template filter '%s'") % filt.func_name + msg = _("incompatible use of template filter '%s'") % ( + pycompat.funcname(filt)) raise error.Abort(msg) def buildmap(exp, context):