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)

See also https://github.com/dcramer/raven/issues/4

Change History (4)

comment:1 by Russell Keith-Magee, 13 years ago

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.

comment:2 by Aymeric Augustin, 13 years ago

Triage Stage: UnreviewedAccepted

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.

Last edited 13 years ago by Aymeric Augustin (previous) (diff)

comment:3 by Aymeric Augustin, 12 years ago

Component: UncategorizedUtilities

comment:4 by Tim Graham, 11 years ago

Resolution: wontfix
Status: newclosed

Marking as won't fix since our copy of dictconfig is deprecated.

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