From c9ebe4ca4e3f5d5d76bfbdae489e3f44e32416e5 Mon Sep 17 00:00:00 2001 From: Hasan Ramezani Date: Fri, 22 Oct 2021 16:38:14 +0200 Subject: [4.0.x] Fixed #33205 -- Made call_command() raise TypeError when dest with multiple arguments is passed. Backport of c1e4111c74ee9d9f48cbee5a5b7c40289203c93d from main --- django/core/management/__init__.py | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'django') diff --git a/django/core/management/__init__.py b/django/core/management/__init__.py index 4e30a28f33..049297b5aa 100644 --- a/django/core/management/__init__.py +++ b/django/core/management/__init__.py @@ -149,6 +149,12 @@ def call_command(command_name, *args, **options): opt.dest in options and (opt.required or opt in mutually_exclusive_required_options) ): + opt_dest_count = sum(v == opt.dest for v in opt_mapping.values()) + if opt_dest_count > 1: + raise TypeError( + f'Cannot pass the dest {opt.dest!r} that matches multiple ' + f'arguments via **options.' + ) parse_args.append(min(opt.option_strings)) if isinstance(opt, (_AppendConstAction, _CountAction, _StoreConstAction)): continue -- cgit v1.3