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

login
register
mail settings
Submitter phabricator
Date Oct. 8, 2017, 8:43 a.m.
Message ID <f8e0872a16a06dd05496628c7d0fb343@localhost.localdomain>
Download mbox | patch
Permalink /patch/24641/
State Not Applicable
Headers show

Comments

phabricator - Oct. 8, 2017, 8:43 a.m.
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




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

Patch

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