mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
Use proper plural forms in argparse (#4391)
This commit is contained in:
parent
13d49ee7d6
commit
1215915045
3 changed files with 10 additions and 4 deletions
|
@ -88,7 +88,7 @@ import re as _re
|
||||||
import sys as _sys
|
import sys as _sys
|
||||||
import textwrap as _textwrap
|
import textwrap as _textwrap
|
||||||
|
|
||||||
from gettext import gettext as _
|
from gettext import gettext as _, ngettext
|
||||||
|
|
||||||
|
|
||||||
def _callable(obj):
|
def _callable(obj):
|
||||||
|
@ -1438,7 +1438,9 @@ class _ActionsContainer(object):
|
||||||
conflict_handler(action, confl_optionals)
|
conflict_handler(action, confl_optionals)
|
||||||
|
|
||||||
def _handle_conflict_error(self, action, conflicting_actions):
|
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
|
conflict_string = ', '.join([option_string
|
||||||
for option_string, action
|
for option_string, action
|
||||||
in conflicting_actions])
|
in conflicting_actions])
|
||||||
|
@ -1995,7 +1997,9 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
|
||||||
OPTIONAL: _('expected at most one argument'),
|
OPTIONAL: _('expected at most one argument'),
|
||||||
ONE_OR_MORE: _('expected at least 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)
|
msg = nargs_errors.get(action.nargs, default)
|
||||||
raise ArgumentError(action, msg)
|
raise ArgumentError(action, msg)
|
||||||
|
|
||||||
|
|
|
@ -4315,7 +4315,7 @@ class TestImportStar(TestCase):
|
||||||
items = [
|
items = [
|
||||||
name
|
name
|
||||||
for name, value in vars(argparse).items()
|
for name, value in vars(argparse).items()
|
||||||
if not name.startswith("_")
|
if not (name.startswith("_") or name == 'ngettext')
|
||||||
if not inspect.ismodule(value)
|
if not inspect.ismodule(value)
|
||||||
]
|
]
|
||||||
self.assertEqual(sorted(items), sorted(argparse.__all__))
|
self.assertEqual(sorted(items), sorted(argparse.__all__))
|
||||||
|
|
|
@ -49,6 +49,8 @@ Core and Builtins
|
||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #4391: Use proper plural forms in argparse.
|
||||||
|
|
||||||
- Issue #10601: sys.displayhook uses 'backslashreplace' error handler on
|
- Issue #10601: sys.displayhook uses 'backslashreplace' error handler on
|
||||||
UnicodeEncodeError.
|
UnicodeEncodeError.
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue