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
7c8ea37d
Commit
7c8ea37d
authored
Apr 04, 2011
by
Steven Bethard
Browse files
Options
Browse Files
Download
Plain Diff
Issue #9347: Fix formatting for tuples in argparse type= error messages.
parents
fc2e3763
7cb20a86
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
6 additions
and
2 deletions
+6
-2
Lib/argparse.py
Lib/argparse.py
+2
-2
Lib/test/test_argparse.py
Lib/test/test_argparse.py
+2
-0
Misc/NEWS
Misc/NEWS
+2
-0
No files found.
Lib/argparse.py
View file @
7c8ea37d
...
...
@@ -1312,13 +1312,13 @@ class _ActionsContainer(object):
# create the action object, and add it to the parser
action_class
=
self
.
_pop_action_class
(
kwargs
)
if
not
_callable
(
action_class
):
raise
ValueError
(
'unknown action "%s"'
%
action_class
)
raise
ValueError
(
'unknown action "%s"'
%
(
action_class
,)
)
action
=
action_class
(
**
kwargs
)
# raise an error if the action type is not callable
type_func
=
self
.
_registry_get
(
'type'
,
action
.
type
,
action
.
type
)
if
not
_callable
(
type_func
):
raise
ValueError
(
'%r is not callable'
%
type_func
)
raise
ValueError
(
'%r is not callable'
%
(
type_func
,)
)
# raise an error if the metavar does not match the type
if
hasattr
(
self
,
"_get_formatter"
):
...
...
Lib/test/test_argparse.py
View file @
7c8ea37d
...
...
@@ -4082,10 +4082,12 @@ class TestInvalidArgumentConstructors(TestCase):
def
test_invalid_type
(
self
):
self
.
assertValueError
(
'--foo'
,
type
=
'int'
)
self
.
assertValueError
(
'--foo'
,
type
=
(
int
,
float
))
def
test_invalid_action
(
self
):
self
.
assertValueError
(
'-x'
,
action
=
'foo'
)
self
.
assertValueError
(
'foo'
,
action
=
'baz'
)
self
.
assertValueError
(
'--foo'
,
action
=
(
'store'
,
'append'
))
parser
=
argparse
.
ArgumentParser
()
try
:
parser
.
add_argument
(
"--foo"
,
action
=
"store-true"
)
...
...
Misc/NEWS
View file @
7c8ea37d
...
...
@@ -349,6 +349,8 @@ Library
-
Issue
#
9026
:
Fix
order
of
argparse
sub
-
commands
in
help
messages
.
-
Issue
#
9347
:
Fix
formatting
for
tuples
in
argparse
type
=
error
messages
.
Build
-----
...
...
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