-
Notifications
You must be signed in to change notification settings - Fork 124
Description
If I call print(args)
in a do_* command function, I get the following stack trace.
Traceback (most recent call last):
File "/home/user/PycharmProjects/cmd2/cmd2/cmd2.py", line 2021, in onecmd_plus_hooks
stop = self.onecmd(statement, add_to_history=add_to_history)
File "/home/user/PycharmProjects/cmd2/cmd2/cmd2.py", line 2451, in onecmd
stop = func(statement)
File "/home/user/PycharmProjects/cmd2/cmd2/decorators.py", line 309, in cmd_wrapper
return func(*args_list, **kwargs)
File "/home/user/PycharmProjects/cmd2/cmd2/cmd2.py", line 2686, in do_alias
print(args)
File "/home/user/miniconda3/envs/cmd2/lib/python3.7/argparse.py", line 122, in repr
arg_strings.append('%s=%r' % (name, value))
File "/home/user/miniconda3/envs/cmd2/lib/python3.7/argparse.py", line 122, in repr
arg_strings.append('%s=%r' % (name, value))
File "/home/user/miniconda3/envs/cmd2/lib/python3.7/argparse.py", line 122, in repr
arg_strings.append('%s=%r' % (name, value))
[Previous line repeated 993 more times]
File "/home/user/miniconda3/envs/cmd2/lib/python3.7/argparse.py", line 120, in repr
for name, value in self._get_kwargs():
File "/home/user/miniconda3/envs/cmd2/lib/python3.7/argparse.py", line 130, in _get_kwargs
return sorted(self.dict.items())
RecursionError: maximum recursion depth exceeded while calling a Python object
EXCEPTION of type 'RecursionError' occurred with message: 'maximum recursion depth exceeded while calling a Python object'
I've narrowed down the cause to this line in decorators.py
setattr(ns, 'get_handler', types.MethodType(get_handler, ns))
This change fixes it
setattr(ns, 'get_handler', functools.partial(get_handler, ns))