Josh Rosenberg <[email protected]> added the comment:
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.
----------
keywords: +needs review
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue14156>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com