Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#19164 closed Bug (fixed)

Argumented added on the LazySettings.setup method, breaks diffsettings command

Reported by: mariocesar Owned by: nobody
Component: Uncategorized Version: 1.4
Severity: Normal Keywords:
Cc: carljm Triage Stage: Accepted
Has patch: no Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Related to ticket #18545, it was added an argument to the setup method of the LazySettings object.

The diffsettings command call settings._setup() to force load all settings and then show to the user.

$ python manage.py diffsettings --traceback
Traceback (most recent call last):
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 222, in run_from_argv
    self.execute(*args, **options.__dict__)
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 252, in execute
    output = self.handle(*args, **options)
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/base.py", line 382, in handle
    return self.handle_noargs(**options)
  File "/home/mariocesar/Proyectos/Crowddeals/env/local/lib/python2.7/site-packages/django/core/management/commands/diffsettings.py", line 19, in handle_noargs
    settings._setup()
TypeError: _setup() takes exactly 2 arguments (1 given)

An option for a fix could be making the argument optional

class LazySettings(LazyObject):
    """
    A lazy proxy for either global Django settings or a custom settings object.
    The user can manually configure settings prior to using them. Otherwise,
    Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
    """
    def _setup(self, name=None):

...

Change History (5)

comment:1 Changed 2 years ago by mariocesar

  • Has patch unset
  • Needs documentation unset
  • Needs tests set
  • Patch needs improvement unset

comment:2 Changed 2 years ago by lrekucki

  • Triage Stage changed from Unreviewed to Accepted

comment:3 Changed 2 years ago by mariocesar

I'm proposing a solution → https://github.com/django/django/pull/461

pd: First time trying to get in order to send a patch, really excited :)

comment:4 Changed 2 years ago by Carl Meyer <carl@…>

  • Resolution set to fixed
  • Status changed from new to closed

In 3541a10d492db6d1f509f3a50a024568c16c5229:

Fixed #19164 -- Fixed diffsettings command broken in fix for #18545.

Thanks Mario César for the report and draft patch.

comment:5 Changed 2 years ago by carljm

Thanks for the report and patch! I used the basic approach, but there was some trouble with running diffsettings in-process using call_command in the test; it seemed to cause trouble with other tests when the full suite was run. I didn't dig deeply into that, instead I added a diffsettings test in the admin_scripts tests which already have a framework for testing management commands in a subprocess.

Also, the possibility of name being None needed to be accounted for later in _setup where name was used.

Note: See TracTickets for help on using tickets.
Back to Top