summaryrefslogtreecommitdiff
path: root/cmd2/cmd2.py
diff options
context:
space:
mode:
authorKevin Van Brunt <kmvanbrunt@gmail.com>2020-08-25 01:46:04 -0400
committerKevin Van Brunt <kmvanbrunt@gmail.com>2020-08-25 10:10:14 -0400
commit9b5a98825a9b00807a40494e8c634c392077ccd2 (patch)
treeb8cfbaca2ec4622a981d96c33c7a964ca621108e /cmd2/cmd2.py
parenta540cfc5373cee2272de6c81be8b6fa8a78c6462 (diff)
downloadcmd2-git-9b5a98825a9b00807a40494e8c634c392077ccd2.tar.gz
Fixed RecursionError when printing an argparse.Namespace caused by custom attribute cmd2 was adding
Added get_statement() function to argparse.Namespace which returns __statement__ attribute
Diffstat (limited to 'cmd2/cmd2.py')
-rw-r--r--cmd2/cmd2.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/cmd2/cmd2.py b/cmd2/cmd2.py
index da576805..bc6691f6 100644
--- a/cmd2/cmd2.py
+++ b/cmd2/cmd2.py
@@ -663,7 +663,9 @@ class Cmd(cmd.Cmd):
raise CommandSetRegistrationError('Could not find argparser for command "{}" needed by subcommand: {}'
.format(command_name, str(method)))
- subcmd_parser.set_defaults(cmd2_handler=method)
+ # Set the subcommand handler function
+ defaults = {constants.NS_ATTR_SUBCMD_HANDLER: method}
+ subcmd_parser.set_defaults(**defaults)
def find_subcommand(action: argparse.ArgumentParser, subcmd_names: List[str]) -> argparse.ArgumentParser:
if not subcmd_names: