Permalink
Browse files

Fixed #29392 -- Disallowed use of abbreviated forms of --settings and…

… --pythonpath management command options.
  • Loading branch information...
rpkilby authored and timgraham committed May 8, 2018
1 parent 265506b commit 2dcc5d629a6439b5547cdd6e67815cabf608fcd4
@@ -311,7 +311,7 @@ def execute(self):
# Preprocess options to extract --settings and --pythonpath.
# These options could affect the commands that are available, so they
# must be processed early.
- parser = CommandParser(usage='%(prog)s subcommand [options] [args]', add_help=False)
+ parser = CommandParser(usage='%(prog)s subcommand [options] [args]', add_help=False, allow_abbrev=False)
parser.add_argument('--settings')
parser.add_argument('--pythonpath')
parser.add_argument('args', nargs='*') # catch-all
View
@@ -423,6 +423,9 @@ Miscellaneous
to insert untranslated content into the database), use the new
:ref:`@no_translations decorator <management-commands-and-locales>`.
+* Management commands no longer allow the abbreviated forms of the
+ ``--settings`` and ``--pythonpath`` arguments.
+
.. _deprecated-features-2.1:
Features deprecated in 2.1
@@ -0,0 +1,10 @@
+from django.core.management.base import BaseCommand
+
+
+class Command(BaseCommand):
+
+ def add_arguments(self, parser):
+ parser.add_argument('--set')
+
+ def handle(self, **options):
+ self.stdout.write('Set %s' % options['set'])
@@ -232,6 +232,16 @@ def test_script_prefix_set_in_commands(self):
self.assertNoOutput(err)
self.assertEqual(out.strip(), '/PREFIX/some/url/')
+ def test_disallowed_abbreviated_options(self):
+ """
+ To avoid conflicts with custom options, commands don't allow
+ abbreviated forms of the --setting and --pythonpath options.
+ """
+ self.write_settings('settings.py', apps=['user_commands'])
+ out, err = self.run_manage(['set_option', '--set', 'foo'])
+ self.assertNoOutput(err)
+ self.assertEqual(out.strip(), 'Set foo')
+
class UtilsTests(SimpleTestCase):

0 comments on commit 2dcc5d6

Please sign in to comment.