Opened 9 years ago

Closed 9 years ago

#25445 closed Cleanup/optimization (needsinfo)

`AttributeError` when `app_config` is missing attribute `models_module` in contenttypes/management.py

Reported by: Clinton Christian Owned by: Clinton Christian
Component: Uncategorized Version: 1.8
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description (last modified by Clinton Christian)

    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

Change History (4)

comment:1 by Clinton Christian, 9 years ago

Summary: `AttributeError` when `app_config` is missing attribute `models_module` in contenttypes/mananagent.py`AttributeError` when `app_config` is missing attribute `models_module` in contenttypes/management.py

comment:2 by Clinton Christian, 9 years ago

Owner: changed from nobody to Clinton Christian
Status: newassigned

comment:3 by Clinton Christian, 9 years ago

Description: modified (diff)

comment:4 by Aymeric Augustin, 9 years ago

Resolution: needsinfo
Status: assignedclosed

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.

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