Patchwork [4,of,8] extensions: 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 <8bc64249b278b7565675.1403635060@augie-macbookair>
Download mbox | patch
Permalink /patch/5059/
State Accepted
Commit 711498bb4ff58874b4920b89a3398aa91ead9060
Headers show

Comments

Augie Fackler - June 24, 2014, 6:37 p.m.
# HG changeset patch
# User Augie Fackler <raf@durin42.com>
# Date 1403529846 14400
#      Mon Jun 23 09:24:06 2014 -0400
# Node ID 8bc64249b278b7565675f2922de6f33a218a1936
# Parent  973a41fae77f5056dc4e5fab0c07227b5d1c8b7e
extensions: restore use of callable() since it was readded in Python 3.2

Patch

diff --git a/mercurial/extensions.py b/mercurial/extensions.py
--- a/mercurial/extensions.py
+++ b/mercurial/extensions.py
@@ -138,7 +138,7 @@ 
     where orig is the original (wrapped) function, and *args, **kwargs
     are the arguments passed to it.
     '''
-    assert util.safehasattr(wrapper, '__call__')
+    assert callable(wrapper)
     aliases, entry = cmdutil.findcmd(command, table)
     for alias, e in table.iteritems():
         if e is entry:
@@ -191,12 +191,12 @@ 
     your end users, you should play nicely with others by using the
     subclass trick.
     '''
-    assert util.safehasattr(wrapper, '__call__')
+    assert callable(wrapper)
     def wrap(*args, **kwargs):
         return wrapper(origfn, *args, **kwargs)
 
     origfn = getattr(container, funcname)
-    assert util.safehasattr(origfn, '__call__')
+    assert callable(origfn)
     setattr(container, funcname, wrap)
     return origfn