summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorÉric Araujo <merwok@netwok.org>2010-12-04 17:31:49 (GMT)
committerÉric Araujo <merwok@netwok.org>2010-12-04 17:31:49 (GMT)
commit1215915045d620d44e14ba12af8949f8ec700b5d (patch)
tree825361ae1cf240c36f075e6db80f24d408928c88
parent13d49ee7d6a44af656fd77713342e419ec57e4a5 (diff)
downloadcpython-1215915045d620d44e14ba12af8949f8ec700b5d.zip
cpython-1215915045d620d44e14ba12af8949f8ec700b5d.tar.gz
cpython-1215915045d620d44e14ba12af8949f8ec700b5d.tar.bz2
Use proper plural forms in argparse (#4391)
-rw-r--r--Lib/argparse.py10
-rw-r--r--Lib/test/test_argparse.py2
-rw-r--r--Misc/NEWS2
3 files changed, 10 insertions, 4 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 747586d..557cc00 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -88,7 +88,7 @@ import re as _re
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 @@ class _ActionsContainer(object):
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 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
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 --git a/Lib/test/test_argparse.py b/Lib/test/test_argparse.py
index 7e76237..0b7ed5e 100644
--- a/Lib/test/test_argparse.py
+++ b/Lib/test/test_argparse.py
@@ -4315,7 +4315,7 @@ class TestImportStar(TestCase):
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 --git a/Misc/NEWS b/Misc/NEWS
index 124fc1c..1e8108e 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -49,6 +49,8 @@ Core and Builtins
Library
-------
+- Issue #4391: Use proper plural forms in argparse.
+
- Issue #10601: sys.displayhook uses 'backslashreplace' error handler on
UnicodeEncodeError.