Code

Opened 3 years ago

Closed 10 months ago

#17052 closed Bug (wontfix)

dictConfig does not correctly handle absolute imports

Reported by: dcramer Owned by: nobody
Component: Utilities Version: master
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

Attachments (0)

Change History (4)

comment:1 Changed 3 years ago by russellm

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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 Changed 3 years ago by aaugustin

  • Triage Stage changed from Unreviewed to 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.

Last edited 3 years ago by aaugustin (previous) (diff)

comment:3 Changed 16 months ago by aaugustin

  • Component changed from Uncategorized to Utilities

comment:4 Changed 10 months ago by timo

  • Resolution set to wontfix
  • Status changed from new to closed

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

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.