summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cmd2/cmd2.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index 3f1696cf..8c9d40b8 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -426,7 +426,7 @@ class Cmd(cmd.Cmd):
cmdset.on_register(self)
methods = inspect.getmembers(
cmdset,
- predicate=lambda meth: (inspect.ismethod(meth) or isinstance(meth, Callable))
+ predicate=lambda meth: isinstance(meth, Callable)
and hasattr(meth, '__name__') and meth.__name__.startswith(COMMAND_FUNC_PREFIX))
installed_attributes = []
@@ -511,7 +511,8 @@ class Cmd(cmd.Cmd):
methods = inspect.getmembers(
cmdset,
- predicate=lambda meth: inspect.ismethod(meth) and meth.__name__.startswith(COMMAND_FUNC_PREFIX))
+ predicate=lambda meth: isinstance(meth, Callable)
+ and hasattr(meth, '__name__') and meth.__name__.startswith(COMMAND_FUNC_PREFIX))
for method in methods:
cmd_name = method[0][len(COMMAND_FUNC_PREFIX):]
@@ -538,7 +539,7 @@ class Cmd(cmd.Cmd):
# find all methods that start with the subcommand prefix
methods = inspect.getmembers(
cmdset,
- predicate=lambda meth: (inspect.ismethod(meth) or isinstance(meth, Callable))
+ predicate=lambda meth: isinstance(meth, Callable)
and hasattr(meth, constants.SUBCMD_ATTR_NAME)
and hasattr(meth, constants.SUBCMD_ATTR_COMMAND)
and hasattr(meth, constants.CMD_ATTR_ARGPARSER)
@@ -583,7 +584,7 @@ class Cmd(cmd.Cmd):
# find all methods that start with the subcommand prefix
methods = inspect.getmembers(
cmdset,
- predicate=lambda meth: (inspect.ismethod(meth) or isinstance(meth, Callable))
+ predicate=lambda meth: isinstance(meth, Callable)
and hasattr(meth, constants.SUBCMD_ATTR_NAME)
and hasattr(meth, constants.SUBCMD_ATTR_COMMAND)
and hasattr(meth, constants.CMD_ATTR_ARGPARSER)