#29906 closed Bug (invalid)
`isinstance(django_settings, type)` triggers ImproperlyConfigured, although settings are not really accessed
Reported by: | Daniel Hahler | Owned by: | nobody |
---|---|---|---|
Component: | Core (Other) | Version: | 2.1 |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Checking if django.conf.settings
is a class should not trigger an exception, but the following code triggers ImproperlyConfigured already:
from django.conf import settings as django_settings isinstance(django_settings, type)
Change History (3)
comment:1 by , 6 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
comment:2 by , 6 years ago
Component: | Uncategorized → Core (Other) |
---|---|
Description: | modified (diff) |
Type: | Uncategorized → Bug |
comment:3 by , 6 years ago
Just for the record: it is not via getattr
, but because
class
itself is special property already: https://github.com/django/django/blob/3d4d0a25b299a97314582156a0d63d939662d310/django/utils/functional.py#L305
I still think that isinstance()
should not throw, but created a fix/workaround for pytest nonetheless.
Version 0, edited 6 years ago by (next)
Note:
See TracTickets
for help on using tickets.
As mentioned on the linked PR this has little to do with the
isinstance
check; accessingdjango.conf.settings
attributes (in this case__class__
throughisinstance
) is prohibited until settings are configured.