# HG changeset patch # User Dan Villiom Podlaski Christiansen # Date 1278666240 -7200 # Node ID 3efadce5b346c63b532d685cbe45a6dbaaf9b1b6 # Parent 94b3bbc886cfee7f5d75da11eaaf21e4c7424d9d extensions: add a few assertions to wrapfunction() and wrapcommand(). Specifically, assert that the given wrapper is callable in both functions, and assert that the original was also callable in wrapfunction(). diff -r 94b3bbc886cf -r 3efadce5b346 mercurial/extensions.py --- a/mercurial/extensions.py Fri Jul 09 11:13:45 2010 +0200 +++ b/mercurial/extensions.py Fri Jul 09 11:04:00 2010 +0200 @@ -116,6 +116,7 @@ where orig is the original (wrapped) function, and *args, **kwargs are the arguments passed to it. ''' + assert hasattr(wrapper, '__call__') aliases, entry = cmdutil.findcmd(command, table) for alias, e in table.iteritems(): if e is entry: @@ -168,10 +169,12 @@ your end users, you should play nicely with others by using the subclass trick. ''' + assert hasattr(wrapper, '__call__') def wrap(*args, **kwargs): return wrapper(origfn, *args, **kwargs) origfn = getattr(container, funcname) + assert hasattr(origfn, '__call__') setattr(container, funcname, wrap) return origfn