[Django] #21634: Lis of installed apps set to empty when ImproperlyConfigured exception is raised

29 views
Skip to first unread message

Django

unread,
Dec 18, 2013, 3:50:03 AM12/18/13
to django-...@googlegroups.com
#21634: Lis of installed apps set to empty when ImproperlyConfigured exception is
raised
--------------------------------------------+--------------------
Reporter: nikolay.v.golub@… | Owner: nobody
Type: Cleanup/optimization | Status: new
Component: Core (Management commands) | Version: 1.6
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------------------+--------------------
This code in django.core.management. !__init!__.py at line 104
{{{
#!div style="font-size: 80%"
Code highlighting:
{{{#!python
# Find the installed apps
from django.conf import settings
try:
apps = settings.INSTALLED_APPS
except ImproperlyConfigured:
# Still useful for commands that do not require functional
settings,
# like startproject or help
apps = []
}}}
}}}
Says, that apps will be set to [] if ImproperlyConfigured exception is
raised. This leads to misunderstanding, when error raised for wrong
configuration of 3rd-party application.

Also this code contradicts PEP-20:
* Explicit is better than implicit
* Errors should never pass silently

For example if you use South, and have any 3rd party app, that can raise
ImproperlyConfigured exception you will get following error when you'll
try to migrate apps db schema:
{{{
Unknown command: 'migrate'
Type 'manage.py help' for usage.
}}}
What purpose of this catching? If something is improperly configured,
maybe user should know about it?

Please, review this ticket and remove this catching.

--
Ticket URL: <https://code.djangoproject.com/ticket/21634>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Dec 18, 2013, 3:50:26 AM12/18/13
to django-...@googlegroups.com
#21634: Lis of installed apps set to empty when ImproperlyConfigured exception is
raised
-------------------------------------+-------------------------------------
Reporter: nikolay.v.golub@… | Owner: nobody
Type: | Status: new
Cleanup/optimization | Version: 1.6
Component: Core (Management | Resolution:
commands) | Triage Stage:
Severity: Normal | Unreviewed
Keywords: | Needs documentation: 0
Has patch: 0 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by nikolay.v.golub@…):

* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/21634#comment:1>

Django

unread,
Dec 18, 2013, 5:03:09 AM12/18/13
to django-...@googlegroups.com
#21634: Lis of installed apps set to empty when ImproperlyConfigured exception is
raised
-------------------------------------+-------------------------------------
Reporter: nikolay.v.golub@… | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: 1.6
Component: Core (Management | Resolution:
commands) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 0 | UI/UX: 0
Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by claudep):

* stage: Unreviewed => Accepted


Comment:

As you can read in the comment, the purpose is to allow to run some
commands even when settings are not yet properly configured. It's obvious
that when you run `django-admin.py startproject`, no suitable settings
will be available.

In [a098bee1b9fa4df] (#19724), we already improved the message for the
`help` command in the case `ImproperlyConfigured` exception is raised. So
I suggest to extend a similar handling for all commands.

--
Ticket URL: <https://code.djangoproject.com/ticket/21634#comment:2>

Django

unread,
May 10, 2014, 2:41:29 PM5/10/14
to django-...@googlegroups.com
#21634: Lis of installed apps set to empty when ImproperlyConfigured exception is
raised
-------------------------------------+-------------------------------------
Reporter: nikolay.v.golub@… | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: 1.6
Component: Core (Management | Resolution:
commands) | Triage Stage: Accepted
Severity: Normal | Needs documentation: 0
Keywords: | Patch needs improvement: 0
Has patch: 1 | UI/UX: 0

Needs tests: 0 |
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by claudep):

* has_patch: 0 => 1


Comment:

PR: https://github.com/django/django/pull/2647

--
Ticket URL: <https://code.djangoproject.com/ticket/21634#comment:3>

Django

unread,
May 13, 2014, 10:03:11 AM5/13/14
to django-...@googlegroups.com
#21634: Lis of installed apps set to empty when ImproperlyConfigured exception is
raised
-------------------------------------+-------------------------------------
Reporter: nikolay.v.golub@… | Owner: nobody

Type: | Status: new
Cleanup/optimization | Version: 1.6
Component: Core (Management | Resolution:
commands) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by timo):

* stage: Accepted => Ready for checkin


--
Ticket URL: <https://code.djangoproject.com/ticket/21634#comment:4>

Django

unread,
May 16, 2014, 5:58:07 AM5/16/14
to django-...@googlegroups.com
#21634: List of installed apps set to empty when ImproperlyConfigured exception is
raised
-------------------------------------+-------------------------------------
Reporter: nikolay.v.golub@… | Owner: erikr
Type: | Status: assigned

Cleanup/optimization | Version: 1.6
Component: Core (Management | Resolution:
commands) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by erikr):

* owner: nobody => erikr
* status: new => assigned


--
Ticket URL: <https://code.djangoproject.com/ticket/21634#comment:5>

Django

unread,
May 16, 2014, 6:09:33 AM5/16/14
to django-...@googlegroups.com
#21634: List of installed apps set to empty when ImproperlyConfigured exception is
raised

-------------------------------------+-------------------------------------
Reporter: nikolay.v.golub@… | Owner: erikr
Type: | Status: closed
Cleanup/optimization | Version: 1.6
Component: Core (Management | Resolution: fixed

commands) | Triage Stage: Ready for
Severity: Normal | checkin
Keywords: | Needs documentation: 0
Has patch: 1 | Patch needs improvement: 0
Needs tests: 0 | UI/UX: 0
Easy pickings: 0 |
-------------------------------------+-------------------------------------
Changes (by Erik Romijn <eromijn@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"f5d4b45df106ad3d37783ef8ea424c030bb6b196"]:
{{{
#!CommitTicketReference repository=""
revision="f5d4b45df106ad3d37783ef8ea424c030bb6b196"
Fixed #21634 -- Prevented hiding ImproperlyConfigured when command not
found

Thanks nikolay...@gmail.com for the report.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/21634#comment:6>

Reply all
Reply to author
Forward
0 new messages