]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
argparse: Remove unused name variable when handling ArgumentTypeError (#96549)
authorJonathon Reinhart <JonathonReinhart@users.noreply.github.com>
Mon, 5 Sep 2022 21:32:23 +0000 (17:32 -0400)
committerGitHub <noreply@github.com>
Mon, 5 Sep 2022 21:32:23 +0000 (14:32 -0700)
This removes the unused `name` variable in the block where `ArgumentTypeError` is handled.

`ArgumentTypeError` errors are handled by showing just the string of the exception; unlike `ValueError`, the name (`__name__`) of the function is not included in the error message.

Fixes #96548

Lib/argparse.py

index fe48f8670fa20a48699e1f20d58a75e5784253b7..d2dcfdf5682f7c18ad18b9974b8d90313278e4ca 100644 (file)
@@ -2523,7 +2523,6 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
 
         # ArgumentTypeErrors indicate errors
         except ArgumentTypeError as err:
-            name = getattr(action.type, '__name__', repr(action.type))
             msg = str(err)
             raise ArgumentError(action, msg)