﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
29392	Command parsing does not handle options that conflict with `--settings`/`--pythonpath`	Ryan P Kilby	nobody	"Argparse performs [https://docs.python.org/3/library/argparse.html#argument-abbreviations-prefix-matching prefix matching] when arguments are unambiguous (e.g., `--set=my.settings` and `--settings=my.settings` are both valid). Since `--settings` and `--pythonpath` are [https://github.com/django/django/blob/2.0/django/core/management/__init__.py#L306-L314 parsed before] the command is fetched, conflicting/ambiguous command options are not checked. For example, if I have a command for getting/setting config values, the result of using the `--set` option is:

{{{
$ python manage.py config --set foo bar
Traceback (most recent call last):
  File ""manage.py"", line 20, in <module>
    execute_from_command_line(sys.argv)
  File "".venv/lib/python3.6/site-packages/django/core/management/__init__.py"", line 364, in execute_from_command_line
    utility.execute()
  File "".venv/lib/python3.6/site-packages/django/core/management/__init__.py"", line 308, in execute
    settings.INSTALLED_APPS
  File "".venv/lib/python3.6/site-packages/django/conf/__init__.py"", line 56, in __getattr__
    self._setup(name)
  File "".venv/lib/python3.6/site-packages/django/conf/__init__.py"", line 41, in _setup
    self._wrapped = Settings(settings_module)
  File "".venv/lib/python3.6/site-packages/django/conf/__init__.py"", line 110, in __init__
    mod = importlib.import_module(self.SETTINGS_MODULE)
  File ""/usr/local/Cellar/python3/3.6.0/Frameworks/Python.framework/Versions/3.6/lib/python3.6/importlib/__init__.py"", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File ""<frozen importlib._bootstrap>"", line 978, in _gcd_import
  File ""<frozen importlib._bootstrap>"", line 961, in _find_and_load
  File ""<frozen importlib._bootstrap>"", line 948, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'foo'
}}}

One solution would be to set [https://docs.python.org/3/library/argparse.html#allow-abbrev allow_abbrev] to `False`, which would disable prefix matching. However, this option is only available in Python 3.5 and above. Also, this might be considered a breaking change if users are expecting to be able to use the abbreviated option names, but I don't know if that's really a concern."	New feature	closed	Core (Management commands)	dev	Normal	fixed			Accepted	0	0	0	0	1	0
