diff options
| author | Hasan Ramezani <hasan.r67@gmail.com> | 2021-10-22 16:38:14 +0200 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-10-25 10:09:06 +0200 |
| commit | c9ebe4ca4e3f5d5d76bfbdae489e3f44e32416e5 (patch) | |
| tree | 108af2ab73ab082133dd937c937198e038fc5f3e /django | |
| parent | ac815f6ea83a66122ee434f773f8c923f4cd3125 (diff) | |
[4.0.x] Fixed #33205 -- Made call_command() raise TypeError when dest with multiple arguments is passed.
Backport of c1e4111c74ee9d9f48cbee5a5b7c40289203c93d from main
Diffstat (limited to 'django')
| -rw-r--r-- | django/core/management/__init__.py | 6 |
1 files changed, 6 insertions, 0 deletions
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 |
