mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
Fix bug 9352 where characters were being lost in parsing some short options
This commit is contained in:
parent
6509599056
commit
1ca45a5292
2 changed files with 31 additions and 7 deletions
|
@ -1794,13 +1794,13 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
|||
chars = self.prefix_chars
|
||||
if arg_count == 0 and option_string[1] not in chars:
|
||||
action_tuples.append((action, [], option_string))
|
||||
for char in self.prefix_chars:
|
||||
option_string = char + explicit_arg[0]
|
||||
explicit_arg = explicit_arg[1:] or None
|
||||
optionals_map = self._option_string_actions
|
||||
if option_string in optionals_map:
|
||||
action = optionals_map[option_string]
|
||||
break
|
||||
char = option_string[0]
|
||||
option_string = char + explicit_arg[0]
|
||||
new_explicit_arg = explicit_arg[1:] or None
|
||||
optionals_map = self._option_string_actions
|
||||
if option_string in optionals_map:
|
||||
action = optionals_map[option_string]
|
||||
explicit_arg = new_explicit_arg
|
||||
else:
|
||||
msg = _('ignored explicit argument %r')
|
||||
raise ArgumentError(action, msg % explicit_arg)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue