Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Savannah Ostrowski <[email protected]>
  • Loading branch information
serhiy-storchaka and savannahostrowski authored Oct 29, 2024
1 parent c3a688b commit 41d67ce
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
10 changes: 5 additions & 5 deletions Lib/test/test_argparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -2386,11 +2386,11 @@ def test_modified_invalid_action(self):
action.type = ()
self.assertRaisesRegex(RuntimeError, r'\(\) is not callable',
parser.parse_args, ['--foo', 'bar'])
# It is impossible to distinguish a TypeError raised due to mismatch
# of the required function arguments from a TypeError raised for wrong
# argument value, and it is not worth to use heavy inspect machinery
# which does not work in all cases anyway.
# So we get a dumb ArgumentError for such logical error.
# It is impossible to distinguish a TypeError raised due to a mismatch
# of the required function arguments from a TypeError raised for an incorrect
# argument value, and using the heavy inspection machinery is not worthwhile
# as it does not reliably work in all cases.
# Therefore, a generic ArgumentError is raised to handle this logical error.
action.type = pow
self.assertRaisesRegex(argparse.ArgumentError,
"argument --foo: invalid pow value: 'bar'",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Fix exceptions in the :mod:`argparse` module. Only error messages for
ArgumentError and ArgumentTypeError are now translated. ArgumentError is now
only used for command line errors, not for logical errors in the program.
Fix exceptions in the :mod:`argparse` module so that only error messages for
:exc:`ArgumentError` and :exc:`ArgumentTypeError` are now translated.
:exc:`ArgumentError` is now only used for command line errors, not for logical
errors in the program.

0 comments on commit 41d67ce

Please sign in to comment.