Patchwork [8,of,8] templater: restore use of callable() since it was readded in Python 3.2

login
register
mail settings
Submitter Augie Fackler
Date June 24, 2014, 6:37 p.m.
Message ID <b3a487010abeac9a5341.1403635064@augie-macbookair>
Download mbox | patch
Permalink /patch/5060/
State Accepted
Commit f2c617ff2abc45f4b704e0edfeda44afe187748f
Headers show

Comments

Augie Fackler - June 24, 2014, 6:37 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1403529896 14400
#      Mon Jun 23 09:24:56 2014 -0400
# Node ID b3a487010abeac9a5341961e1dbcf0237374c371
# Parent  57b09c58165f42eb8eccc7be8ebd89101fb95914
templater: restore use of callable() since it was readded in Python 3.2
Matt Mackall - June 24, 2014, 6:49 p.m.
On Tue, 2014-06-24 at 14:37 -0400, Augie Fackler wrote:
> # HG changeset patch
> # User Augie Fackler <raf@durin42.com>
> # Date 1403529896 14400
> #      Mon Jun 23 09:24:56 2014 -0400
> # Node ID b3a487010abeac9a5341961e1dbcf0237374c371
> # Parent  57b09c58165f42eb8eccc7be8ebd89101fb95914
> templater: restore use of callable() since it was readded in Python 3.2

These are queued, thanks.

Patch

diff --git a/mercurial/templater.py b/mercurial/templater.py
--- a/mercurial/templater.py
+++ b/mercurial/templater.py
@@ -148,7 +148,7 @@ 
             v = context.process(key, mapping)
         except TemplateNotFound:
             v = ''
-    if util.safehasattr(v, '__call__'):
+    if callable(v):
         return v(**mapping)
     if isinstance(v, types.GeneratorType):
         v = list(v)
@@ -185,7 +185,7 @@ 
 def runmap(context, mapping, data):
     func, data, ctmpl = data
     d = func(context, mapping, data)
-    if util.safehasattr(d, '__call__'):
+    if callable(d):
         d = d()
 
     lm = mapping.copy()
@@ -335,7 +335,7 @@ 
         raise error.ParseError(_("join expects one or two arguments"))
 
     joinset = args[0][0](context, mapping, args[0][1])
-    if util.safehasattr(joinset, '__call__'):
+    if callable(joinset):
         jf = joinset.joinfmt
         joinset = [jf(x) for x in joinset()]