From 0b6926826a855517cc0cc126fc32c1763f5b146e Mon Sep 17 00:00:00 2001 From: James Vega Date: Mon, 5 Jan 2009 23:11:09 +0000 Subject: [PATCH] Make sure getCommandMethod only returns a valid command method In situations like an alias, simply using getattr(self, command[0]) may return a class method instead of the alias (think "Alias add die ..."). --- src/callbacks.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/callbacks.py b/src/callbacks.py index 1f9ee8087..837d6ba9f 100644 --- a/src/callbacks.py +++ b/src/callbacks.py @@ -1135,7 +1135,13 @@ class Commands(BasePlugin): assert command[0] == self.canonicalName() return self.getCommandMethod(command[1:]) else: - return getattr(self, command[0]) + method = getattr(self, command[0]) + if inspect.ismethod(method): + code = method.im_func.func_code + if inspect.getargs(code)[0] == self.commandArgs: + return method + else: + raise AttributeError def listCommands(self): commands = []