(original) (raw)
changeset: 66721:1827a8ac9b18 parent: 66719:ba709ad3ff4c user: Éric Araujo merwok@netwok.org date: Sat Dec 04 17:31:49 2010 +0000 files: Lib/argparse.py Lib/test/test_argparse.py Misc/NEWS description: Use proper plural forms in argparse (#4391) diff -r ba709ad3ff4c -r 1827a8ac9b18 Lib/argparse.py --- a/Lib/argparse.py Sat Dec 04 17:24:33 2010 +0000 +++ b/Lib/argparse.py Sat Dec 04 17:31:49 2010 +0000 @@ -88,7 +88,7 @@ import sys as _sys import textwrap as _textwrap -from gettext import gettext as _ +from gettext import gettext as _, ngettext def _callable(obj): @@ -1438,7 +1438,9 @@ conflict_handler(action, confl_optionals) def _handle_conflict_error(self, action, conflicting_actions): - message = _('conflicting option string(s): %s') + message = ngettext('conflicting option string: %s', + 'conflicting option strings: %s', + len(conflicting_actions)) conflict_string = ', '.join([option_string for option_string, action in conflicting_actions]) @@ -1995,7 +1997,9 @@ OPTIONAL: _('expected at most one argument'), ONE_OR_MORE: _('expected at least one argument'), } - default = _('expected %s argument(s)') % action.nargs + default = ngettext('expected %s argument', + 'expected %s arguments', + action.nargs) % action.nargs msg = nargs_errors.get(action.nargs, default) raise ArgumentError(action, msg) diff -r ba709ad3ff4c -r 1827a8ac9b18 Lib/test/test_argparse.py --- a/Lib/test/test_argparse.py Sat Dec 04 17:24:33 2010 +0000 +++ b/Lib/test/test_argparse.py Sat Dec 04 17:31:49 2010 +0000 @@ -4315,7 +4315,7 @@ items = [ name for name, value in vars(argparse).items() - if not name.startswith("_") + if not (name.startswith("_") or name == 'ngettext') if not inspect.ismodule(value) ] self.assertEqual(sorted(items), sorted(argparse.__all__)) diff -r ba709ad3ff4c -r 1827a8ac9b18 Misc/NEWS --- a/Misc/NEWS Sat Dec 04 17:24:33 2010 +0000 +++ b/Misc/NEWS Sat Dec 04 17:31:49 2010 +0000 @@ -49,6 +49,8 @@ Library ------- +- Issue #4391: Use proper plural forms in argparse. + - Issue #10601: sys.displayhook uses 'backslashreplace' error handler on UnicodeEncodeError. /merwok@netwok.org