The return statement is never reached since if app_config doesn't have a
`models_module` attribute it raises an AttributeError.
Regardless of whether to allow the return statement to catch or return an
AttributeError, this code should perhaps be changed to be more clear. I
suggest either raising an AttributeError explicitly or using gettattr.
https://github.com/django/django/pull/5338
--
Ticket URL: <https://code.djangoproject.com/ticket/25445>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_docs: => 0
* needs_tests: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/25445#comment:1>
* owner: nobody => pygeek
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/25445#comment:2>
Old description:
> ```
> if not app_config.models_module:
> return
> ```
>
> The return statement is never reached since if app_config doesn't have a
> `models_module` attribute it raises an AttributeError.
>
> Regardless of whether to allow the return statement to catch or return an
> AttributeError, this code should perhaps be changed to be more clear. I
> suggest either raising an AttributeError explicitly or using gettattr.
>
> https://github.com/django/django/pull/5338
New description:
{{{
if not app_config.models_module:
return
}}}
The return statement is never reached since if `app_config` doesn't have a
`models_module` attribute it raises an `AttributeError`.
Regardless of whether to allow the return statement to catch or return an
`AttributeError`, this code should perhaps be changed to be more clear. I
suggest either raising an `AttributeError` explicitly or using `gettattr`.
https://github.com/django/django/pull/5338
--
--
Ticket URL: <https://code.djangoproject.com/ticket/25445#comment:3>
* status: assigned => closed
* resolution: => needsinfo
Comment:
Have you encountered an error in practice or are you simply suggesting
this fix based on code inspection?
Considering that `AppConfig.__init__` assigns `self.models_module = None`,
I fail to see how `models_module` can be missing.
--
Ticket URL: <https://code.djangoproject.com/ticket/25445#comment:4>