Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
12159150
Commit
12159150
authored
Dec 04, 2010
by
Éric Araujo
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use proper plural forms in argparse (#4391)
parent
13d49ee7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
10 additions
and
4 deletions
+10
-4
Lib/argparse.py
Lib/argparse.py
+7
-3
Lib/test/test_argparse.py
Lib/test/test_argparse.py
+1
-1
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/argparse.py
View file @
12159150
...
...
@@ -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
)
...
...
Lib/test/test_argparse.py
View file @
12159150
...
...
@@ -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__
))
...
...
Misc/NEWS
View file @
12159150
...
...
@@ -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.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment