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 ...").
This commit is contained in:
James Vega 2009-01-05 23:11:09 +00:00
parent 62897a9663
commit 0b6926826a

View File

@ -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 = []