Fix debugger-aware parsing for int arguments in subcommands (#3432)

pull/3433/head
jackmisbach 2 weeks ago committed by GitHub
parent 4f7e515775
commit e65f384843
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -228,15 +228,22 @@ class CommandObj:
# We want to run all integer and otherwise-unspecified arguments
# through fix() so that GDB parses it.
# FIXME: this is weird
for action in self.parser._actions:
if isinstance(action, argparse._SubParsersAction):
action.type = str
if action.dest == "help":
continue
if action.type is int:
action.type = fix_int_reraise_arg
elif action.type is None:
action.type = fix_reraise_arg
def process_actions(actions):
"""Recursively process actions, including subparsers"""
for action in actions:
if isinstance(action, argparse._SubParsersAction):
action.type = str
# Recursively process each subparser's actions
for subparser in action.choices.values():
process_actions(subparser._actions)
if action.dest == "help":
continue
if action.type is int:
action.type = fix_int_reraise_arg
elif action.type is None:
action.type = fix_reraise_arg
process_actions(self.parser._actions)
assert (
self.parser.formatter_class is argparse.HelpFormatter

Loading…
Cancel
Save