[Django] #31870: App with default_app_config in init crashes

20 views
Skip to first unread message

Django

unread,
Aug 9, 2020, 8:52:53 AM8/9/20
to django-...@googlegroups.com
#31870: App with default_app_config in init crashes
------------------------------------------+------------------------
Reporter: Iuri de Silvio | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
------------------------------------------+------------------------
If I don't have an `apps.py` and the `default_app_config` is in
`__init__.py`, it fails.

{{{
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
main()
File "./manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "django/core/management/__init__.py", line 401, in
execute_from_command_line
utility.execute()
File "django/core/management/__init__.py", line 377, in execute
django.setup()
File "django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "django/apps/config.py", line 157, in create
if new_entry == app_config_name:
UnboundLocalError: local variable 'app_config_name' referenced before
assignment
}}}

Looks like a regression added in
https://code.djangoproject.com/ticket/31180.

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

Django

unread,
Aug 9, 2020, 8:53:00 AM8/9/20
to django-...@googlegroups.com
#31870: App with default_app_config in init crashes
--------------------------------+------------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de Silvio
Type: Bug | Status: assigned
Component: Uncategorized | Version: 3.1
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------
Changes (by Iuri de Silvio):

* owner: nobody => Iuri de Silvio
* status: new => assigned


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

Django

unread,
Aug 9, 2020, 9:04:33 AM8/9/20
to django-...@googlegroups.com
#31870: App with default_app_config in init crashes
--------------------------------+------------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de Silvio
Type: Bug | Status: assigned
Component: Uncategorized | Version: 3.1
Severity: Normal | Resolution:

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
--------------------------------+------------------------------------------
Description changed by Iuri de Silvio:

Old description:

> If I don't have an `apps.py` and the `default_app_config` is in
> `__init__.py`, it fails.
>
> {{{
> Traceback (most recent call last):
> File "./manage.py", line 22, in <module>
> main()
> File "./manage.py", line 18, in main
> execute_from_command_line(sys.argv)
> File "django/core/management/__init__.py", line 401, in
> execute_from_command_line
> utility.execute()
> File "django/core/management/__init__.py", line 377, in execute
> django.setup()
> File "django/__init__.py", line 24, in setup
> apps.populate(settings.INSTALLED_APPS)
> File "django/apps/registry.py", line 91, in populate
> app_config = AppConfig.create(entry)
> File "django/apps/config.py", line 157, in create
> if new_entry == app_config_name:
> UnboundLocalError: local variable 'app_config_name' referenced before
> assignment
> }}}
>
> Looks like a regression added in
> https://code.djangoproject.com/ticket/31180.

New description:

If I don't have an `apps.py` and the `default_app_config` is in
`__init__.py`, it fails.

{{{
Traceback (most recent call last):
File "./manage.py", line 22, in <module>
main()
File "./manage.py", line 18, in main
execute_from_command_line(sys.argv)
File "django/core/management/__init__.py", line 401, in
execute_from_command_line
utility.execute()
File "django/core/management/__init__.py", line 377, in execute
django.setup()
File "django/__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "django/apps/config.py", line 157, in create
if new_entry == app_config_name:
UnboundLocalError: local variable 'app_config_name' referenced before
assignment
}}}

If the `apps.py` is there, but the `default_app_config` is in
`__init__.py`, it fails too.

{{{
Traceback (most recent call last):

File "django/django/test/utils.py", line 381, in inner
return func(*args, **kwargs)
File "django/tests/apps/tests.py", line 541, in
test_explicit_default_app_config_with_empty_apps
with
self.settings(INSTALLED_APPS=['apps.explicit_default_config_with_empty_apps']):
File "django/django/test/utils.py", line 336, in __enter__
return self.enable()
File "django/django/test/utils.py", line 410, in enable
apps.set_installed_apps(self.options['INSTALLED_APPS'])
File "django/django/apps/registry.py", line 355, in set_installed_apps
self.populate(installed)
File "django/django/apps/registry.py", line 91, in populate
app_config = AppConfig.create(entry)
File "django/django/apps/config.py", line 160, in create


if new_entry == app_config_name:
UnboundLocalError: local variable 'app_config_name' referenced before
assignment
}}}

Looks like a regression added in
https://code.djangoproject.com/ticket/31180.

--

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

Django

unread,
Aug 10, 2020, 12:38:05 AM8/10/20
to django-...@googlegroups.com
#31870: App with default_app_config and without apps.py or with an empty apps.py
crashes.
-------------------------------------+-------------------------------------

Reporter: Iuri de Silvio | Owner: Iuri de
| Silvio
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 1

Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* severity: Normal => Release blocker
* cc: Aymeric Augustin (added)
* needs_better_patch: 0 => 1
* component: Uncategorized => Core (Other)
* version: 3.1 => master
* has_patch: 0 => 1
* stage: Unreviewed => Accepted


Comment:

Thanks for the report.

Regression in 3f2821af6bc48fa8e7970c1ce27bc54c3172545e.
Reproduced at b2b0711b555fa292751763c2df4fe577c396f265.

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

Django

unread,
Aug 10, 2020, 5:14:38 AM8/10/20
to django-...@googlegroups.com
#31870: App with default_app_config and without apps.py or with an empty apps.py
crashes.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
| Silvio
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Changes (by Iuri de Silvio):

* needs_better_patch: 1 => 0


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

Django

unread,
Aug 10, 2020, 6:21:05 AM8/10/20
to django-...@googlegroups.com
#31870: App with default_app_config and without apps.py or with an empty apps.py
crashes.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
| Silvio
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by felixxm):

* stage: Accepted => Ready for checkin


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

Django

unread,
Aug 10, 2020, 8:06:48 AM8/10/20
to django-...@googlegroups.com
#31870: App with default_app_config and without apps.py or with an empty apps.py
crashes.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
| Silvio
Type: Bug | Status: assigned
Component: Core (Other) | Version: master
Severity: Release blocker | Resolution:
Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------

Comment (by Aymeric Augustin):

The PR is very good. Thanks.

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

Django

unread,
Aug 10, 2020, 2:17:34 PM8/10/20
to django-...@googlegroups.com
#31870: App with default_app_config and without apps.py or with an empty apps.py
crashes.
-------------------------------------+-------------------------------------
Reporter: Iuri de Silvio | Owner: Iuri de
| Silvio
Type: Bug | Status: closed

Component: Core (Other) | Version: master
Severity: Release blocker | Resolution: fixed

Keywords: | Triage Stage: Ready for
| checkin
Has patch: 1 | Needs documentation: 0

Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by GitHub <noreply@…>):

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


Comment:

In [changeset:"ebd78a9f97d8ba850d279a844d89a1d805370738" ebd78a9f]:
{{{
#!CommitTicketReference repository=""
revision="ebd78a9f97d8ba850d279a844d89a1d805370738"
Fixed #31870 -- Fixed crash when populating app registry with empty or
without apps module.

Regression in 3f2821af6bc48fa8e7970c1ce27bc54c3172545e.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/31870#comment:7>

Reply all
Reply to author
Forward
0 new messages