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 paul.j3
Recipients DenKoren, bethard, paul.j3
Date 2014-09-20.22:58:18
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1411253898.52.0.113275383247.issue22433@psf.upfronthosting.co.za>
In-reply-to
Content
Your patch fails:

    python3 -m unittest test_argparse.TestEmptyAndSpaceContainingArguments

specifically these 2 subcases:

       (['-a badger'], NS(x='-a badger', y=None)),
       (['-y', '-a badger'], NS(x=None, y='-a badger')),

--------------------

At issue is the ambiguity when the user gives you a string that looks like an optionals flag, but doesn't match one of the defined arguments.  When should it be treated as a positional, and when should it be treated as an unknown?

The code, and test says - if it has the space, treat it like a positional.  You are trying to reverse that choice - if it has the prefix, treat it like an unknown optional.  At the point where you apply the patch, we already know that the string has a prefixchar.  So you are, effectively, eliminating the 'space' test.

I've added a simpler example of where the presence of the space flips that choice.
History
Date User Action Args
2014-09-20 22:58:18paul.j3setrecipients: + paul.j3, bethard, DenKoren
2014-09-20 22:58:18paul.j3setmessageid: <1411253898.52.0.113275383247.issue22433@psf.upfronthosting.co.za>
2014-09-20 22:58:18paul.j3linkissue22433 messages
2014-09-20 22:58:18paul.j3create