This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author evaned
Recipients Christophe.Guillon, Clint Olsen, abacabadabacaba, amcnabb, andersk, bethard, cben, danielsh, davidben, drm, eric.araujo, eric.smith, evaned, gdb, gfxmonk, martin.panter, memeplex, nelhage, paul.j3, r.david.murray, skilletaudio, spaceone
Date 2017-11-29.05:54:47
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
> I also think that nargs=## could maybe be special-cased to just ignore 
> the A/O designation completely and only check there are enough, but I 
> haven't tried this out. Does this seem like a viable approach? Would a 
> patch that does that, subject to some flag, be of interest?

I can't leave well enough alone, so, with the following additional patch:

-    def _match_argument(self, action, arg_strings_pattern):
+    def _match_argument(self, action, arg_strings_pattern, arg_strings, start_index):
+        import numbers
+        nargs = action.nargs if action.nargs is not None else 1
+        if isinstance(nargs, numbers.Number) and len(arg_strings_pattern) >= nargs:
+            return nargs
         # match the pattern for this action to the arg strings
         nargs_pattern = self._get_nargs_pattern(action)
         match = _re.match(nargs_pattern, arg_strings_pattern)

Then I get this:

  >>> import argparse
  >>> parser = argparse.ArgumentParser(prog='a2x')
  >>> parser.add_argument('--asciidoc-opts',
  ...     action='store', dest='asciidoc_opts', default='',
  ...     metavar='ASCIIDOC_OPTS', help='asciidoc options')
  >>> parser.parse_args(['--asciidoc-opts', '--safe'])

Comments on this approach?

(Again, I haven't run tests, it'd need to be controlled by a flag per your desire to not change existing behavior, etc.)
Date User Action Args
2017-11-29 05:54:48evanedsetrecipients: + evaned, cben, amcnabb, bethard, eric.smith, eric.araujo, r.david.murray, memeplex, gfxmonk, andersk, abacabadabacaba, gdb, nelhage, drm, davidben, martin.panter, paul.j3, skilletaudio, Christophe.Guillon, danielsh, spaceone, Clint Olsen
2017-11-29 05:54:48evanedsetmessageid: <>
2017-11-29 05:54:48evanedlinkissue9334 messages
2017-11-29 05:54:47evanedcreate