Opened 13 years ago
Closed 11 years ago
#17052 closed Bug (wontfix)
dictConfig does not correctly handle absolute imports
Reported by: | David Cramer | Owned by: | nobody |
---|---|---|---|
Component: | Utilities | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | Triage Stage: | Accepted | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
When you have a module, say foo.bar.logging.Handler, and you try to register that with dictConfig it will cause an import error due to the way the recursive importing was implemented.
While we're not using Django for this, we are using logutils (which is still the same code):
https://github.com/django/django/blob/master/django/utils/dictconfig.py#L157
We patched it by simply using import correctly:
class NotBrokenDictConfig(logutils.dictconfig.DictConfigurator): def resolve(self, s): module, cls_name = s.rsplit('.', 1) return getattr(self.importer(module, {}, {}, [cls_name]), cls_name)
Change History (4)
comment:1 by , 13 years ago
comment:2 by , 13 years ago
Triage Stage: | Unreviewed → Accepted |
---|
As this query shows, this wasn't reported in Python's bug tracker yet.
We'll have to backport the fix from Python eventually, so I'm marking this as accepted.
comment:3 by , 12 years ago
Component: | Uncategorized → Utilities |
---|
comment:4 by , 11 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
Marking as won't fix since our copy of dictconfig
is deprecated.
To clarify: you appear to be reporting an issue with dictconfig itself -- is this correct? If so, has it been reported and/or fixed in Python's native dictconfig?
Django's dictconfig is a literal copy of the one included in Python, included verbatim to ensure compatibility across Python versions. If there's a problem with the version bundled with Django, the preferred fix is to update to a new verbatim copy, not to patch Django's version.