D964: python3: add and use adapter for func_name attr, now known as __name__

durin42 (Augie Fackler) phabricator at mercurial-scm.org
Sun Oct 8 04:43:01 EDT 2017


This revision was automatically updated to reflect the committed changes.
Closed by commit rHG68faf082bdcd: python3: add and use adapter for func_name attr, now known as __name__ (authored by durin42, committed by ).

REPOSITORY
  rHG Mercurial

CHANGES SINCE LAST UPDATE
  https://phab.mercurial-scm.org/D964?vs=2480&id=2525

REVISION DETAIL
  https://phab.mercurial-scm.org/D964

AFFECTED FILES
  mercurial/peer.py
  mercurial/pycompat.py
  mercurial/templater.py

CHANGE DETAILS

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):
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/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



To: durin42, #hg-reviewers, pulkit, indygreg, yuja
Cc: yuja, indygreg, mercurial-devel


More information about the Mercurial-devel mailing list