#25445: `AttributeError` when `app_config` is missing attribute `models_module` 
in
contenttypes/management.py
-------------------------------------+-------------------------------------
     Reporter:  pygeek               |                    Owner:  pygeek
         Type:                       |                   Status:  assigned
  Cleanup/optimization               |
    Component:  Uncategorized        |                  Version:  1.8
     Severity:  Normal               |               Resolution:
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Description changed by pygeek:

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>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/064.41d5a4f806d6569fc2c64b6564c528a2%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to