[commands] Fix bug where subgroups would be repeatedly called.

This happened due to not resetting the `invoked_subcommand` state
tracking. Since the `invoked_subcommand` was not reset, it would always
assume that it was valid and repeatedly call it when passed invalid
subcommands/arguments.
This commit is contained in:
Rapptz 2016-06-04 22:04:05 -04:00
parent 24a9da04db
commit 9d9a20c128

View File

@ -367,6 +367,11 @@ class Command:
def invoke(self, ctx):
self._verify_checks(ctx)
yield from self._parse_arguments(ctx)
# terminate the invoked_subcommand chain.
# since we're in a regular command (and not a group) then
# the invoked subcommand is None.
ctx.invoked_subcommand = None
injected = inject_context(ctx, self.callback)
yield from injected(*ctx.args, **ctx.kwargs)
@ -593,8 +598,7 @@ class Group(GroupMixin, Command):
if trigger:
ctx.subcommand_passed = trigger
if trigger in self.commands:
ctx.invoked_subcommand = self.commands[trigger]
ctx.invoked_subcommand = self.commands.get(trigger, None)
if early_invoke:
injected = inject_context(ctx, self.callback)