summaryrefslogtreecommitdiffstats
path: root/Lib/argparse.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/argparse.py')
-rw-r--r--Lib/argparse.py6
1 files changed, 4 insertions, 2 deletions
diff --git a/Lib/argparse.py b/Lib/argparse.py
index 55bf8cd..64893b5 100644
--- a/Lib/argparse.py
+++ b/Lib/argparse.py
@@ -1871,8 +1871,10 @@ class ArgumentParser(_AttributeHolder, _ActionsContainer):
def parse_args(self, args=None, namespace=None):
args, argv = self.parse_known_args(args, namespace)
if argv:
- msg = _('unrecognized arguments: %s')
- self.error(msg % ' '.join(argv))
+ msg = _('unrecognized arguments: %s') % ' '.join(argv)
+ if self.exit_on_error:
+ self.error(msg)
+ raise ArgumentError(None, msg)
return args
def parse_known_args(self, args=None, namespace=None):