Author josh.r
Recipients Leo Singer, Marcel H2, bethard, eli.bendersky, evan_, josh.r, markgrandi, moritz, naufraghi, palaviv, paul.j3, r.david.murray, sedrubal, serhiy.storchaka
Date 2019-05-07.18:52:07
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1557255127.48.0.146175661753.issue14156@roundup.psfhosted.org>
In-reply-to
Content
I've created PR13165 to address this bug. It's 99% test updates; the actual code changes to argparse.py are trivial and should be equally trivial to review.

The only functional change beyond Moritz's proposal is that I added support for having accepting '-' when the mode string uses 'a' or 'x' instead of 'w'; for sys.stdout, they're all effectively equivalent ('x' is trying to prevent stomping an existing file, which borrowing sys.stdout won't do, and sys.stdout is already more closely equivalent to mode 'a' in any event). No working code should break as a result of that change (passing 'a' or 'x' previously just caused FileType to exit immediately with a ValueError, which in turn caused parse_args to kill the program, which I'm assuming isn't considered a valuable "feature").

In addition to testing binary mode with argument '-' properly, I also added complete test cases for mode 'x' and 'xb' (for all arguments, both file names and '-') since we had no such tests, and ensuring exclusive creation mode behaves correctly is fairly important.
History
Date User Action Args
2019-05-07 18:52:07josh.rsetrecipients: + josh.r, bethard, naufraghi, r.david.murray, eli.bendersky, paul.j3, serhiy.storchaka, moritz, markgrandi, palaviv, evan_, sedrubal, Marcel H2, Leo Singer
2019-05-07 18:52:07josh.rsetmessageid: <1557255127.48.0.146175661753.issue14156@roundup.psfhosted.org>
2019-05-07 18:52:07josh.rlinkissue14156 messages
2019-05-07 18:52:07josh.rcreate