[Python-checkins] argparse: Remove unused name variable when handling ArgumentTypeError (#96549)

JelleZijlstra webhook-mailer at python.org
Mon Sep 5 17:32:31 EDT 2022


https://github.com/python/cpython/commit/30878a7735f7d5cf2023f5b2758feee850b60700
commit: 30878a7735f7d5cf2023f5b2758feee850b60700
branch: main
author: Jonathon Reinhart <JonathonReinhart at users.noreply.github.com>
committer: JelleZijlstra <jelle.zijlstra at gmail.com>
date: 2022-09-05T14:32:23-07:00
summary:

argparse: Remove unused name variable when handling ArgumentTypeError (#96549)

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

files:
M Lib/argparse.py

diff --git a/Lib/argparse.py b/Lib/argparse.py
index fe48f8670fa..d2dcfdf5682 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -2523,7 +2523,6 @@ def _get_value(self, action, arg_string):
 
         # ArgumentTypeErrors indicate errors
         except ArgumentTypeError as err:
-            name = getattr(action.type, '__name__', repr(action.type))
             msg = str(err)
             raise ArgumentError(action, msg)
 



More information about the Python-checkins mailing list