{{{
$ 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.
--
Ticket URL: <https://code.djangoproject.com/ticket/29392>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* version: 2.0 => master
* type: Bug => New feature
* stage: Unreviewed => Accepted
Comment:
Hi Ryan. Thanks for the report. This seems reasonable.
Interestingly, with the patch, if you pass an abbreviation to second
parser you get the error you'd expect:
manage.py config: error: ambiguous option: --se could match --set,
--settings
> ...this option is only available in Python 3.5 and above.
Right. For that reason lets call this a New Feature and roll it into 2.1,
where we don't have to worry about compat. (This has existed for ≈forever
so I can't see the harm in holding off slightly.)
> 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.
Yes, probably not a biggie but could you add a note to the Breaking
changes section in `2.1.txt`.
--
Ticket URL: <https://code.djangoproject.com/ticket/29392#comment:1>
* owner: nobody => lefcourn
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/29392#comment:2>
Comment (by Ryan P Kilby):
Thanks for the review Carlton. Added a note to the misc backwards
incompatibility section.
--
Ticket URL: <https://code.djangoproject.com/ticket/29392#comment:3>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"2dcc5d629a6439b5547cdd6e67815cabf608fcd4" 2dcc5d62]:
{{{
#!CommitTicketReference repository=""
revision="2dcc5d629a6439b5547cdd6e67815cabf608fcd4"
Fixed #29392 -- Disallowed use of abbreviated forms of --settings and
--pythonpath management command options.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/29392#comment:4>
Comment (by lefcourn):
Sorry, didn't realize that there was already a commit for this issue when
I assigned it to myself.
--
Ticket URL: <https://code.djangoproject.com/ticket/29392#comment:5>