Skip to content

Commit 285da4a

Browse files
committed
After review comments
1 parent 2b47dda commit 285da4a

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

Lib/argparse.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
17771777
error info when an error occurs
17781778
- suggest_on_error - Enables suggestions for mistyped argument choices
17791779
and subparser names. (default: ``False``)
1780-
- convert_choices - Runs the ``choices`` through the ``type`` function
1780+
- convert_choices - Runs the ``choices`` through the ``type`` callable
17811781
during checking. (default: ``False``)
17821782
"""
17831783

@@ -2593,11 +2593,7 @@ def _check_value(self, action, value, arg_string=None):
25932593
action.type and
25942594
all(isinstance(choice, str) for choice in choices)
25952595
):
2596-
try:
2597-
typed_choices = [action.type(v) for v in choices]
2598-
except Exception:
2599-
# We use a blanket catch here, because type is user provided.
2600-
pass
2596+
typed_choices = [action.type(v) for v in choices]
26012597

26022598
if value not in choices and value not in typed_choices:
26032599
args = {'value': arg_string,

Lib/test/test_argparse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1935,7 +1935,7 @@ def setUp(self):
19351935
]
19361936

19371937
class TestChoices(ParserTestCase):
1938-
"""Test the original behavior"""
1938+
"""Test integer choices without conversion."""
19391939
def to_dow(arg):
19401940
days = ["mo", "tu", "we", "th", "fr", "sa", "su"]
19411941
if arg in days:

0 commit comments

Comments
 (0)