Export to GitHub

logutils - issue #1

Import paths are incorrectly resolved


Posted on Oct 10, 2011 by Quick Cat

logutils.dictconfig.DictConfigurator uses a weird method to resolve imports which break if absolute imports are opted in, in the target module.

To reproduce:

Write a handler in a module that uses 'from future import absolute_imports'. See it not being able to be referenced in the config.

Use import + sys.modules lookup instead or getattr around import.

Comment #1

Posted on Oct 10, 2011 by Quick Cat

This is a simple fix for the problem: http://pastie.org/private/ihjcylqxgtgxpsevtzmsw

Comment #2

Posted on Nov 21, 2011 by Swift Lion

I'm not quite sure what you mean: I added a unit test in 0.3.2 which includes a handler "mytest.MyTestHandler', and the test passes. Can you suggest a change to this unit test (available in the 0.3.2 tarball) which will show up the failure? Thanks.

Comment #3

Posted on Mar 1, 2014 by Swift Lion

With the following handler module:

--- dchandler.py ---

from future import absolute_import

import logging

class MyHandler(logging.StreamHandler): pass

--- end of dchandler.py ---

If I run the following test script:

--- dctest.py ---

import logging import logutils.dictconfig

LOGGING = { 'version': 1, 'handlers': { 'mine': { 'class': 'dchandler.MyHandler', }, }, 'root': { 'handlers': ['mine'], 'level': 'DEBUG', } }

logutils.dictconfig.dictConfig(LOGGING)

logging.debug('Test')

--- end of dctest.py ---

I get no errors and the script prints 'Test', as expected.

(Tested with Python 2.7 and logutils 0.3.3).

Status: Invalid

Labels:
Type-Defect Priority-Medium