Anthony Sottile <asott...@umich.edu> added the comment: The intention of the change in issue 26510 was to pick the least surprising behaviour for the default value of subparsers -- the compatiblity with the behaviour before the regression was introduced in 3.3 was a nice side-effect. As with the rest of positional arguments in argparse, the positional subparsers were changed to required by default.
The main issue addressing the 3.3 regression I believe is https://bugs.python.org/issue9253 and not the one linked. When I revived the patch, I surveyed a number of open source tools using subparsers (~10-20) and they all fell into the following categories: - Used the workaround (part of this SO post: https://stackoverflow.com/a/23354355/812183) (most fell into this category) - crashed with some sort of TypeError (NoneType has no attribute startswith, KeyeError: None, etc.) due to not handling "optional" subparsers - Manually handled when the subparser was `None` to raise an argparse error You can enable a 3.3-3.7 compatible "always optional subparsers" with a similar pattern that was used to manually restore the pre-regression behaviour: subparsers = parser.add_subparsers(...) subparsers.required = False I believe the error message issue is already tracked: https://bugs.python.org/issue29298 ---------- _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue33109> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com