Opened 7 years ago

Closed 7 years ago

#16585 closed Bug (invalid)

BaseConfigurator importer logical mistake

Reported by: Alexandr Owned by: nobody
Component: Core (Other) Version: 1.3
Severity: Normal Keywords: logging, dictconfig
Cc: Triage Stage: Unreviewed
Has patch: yes Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


"BaseConfigurator.importer" method doesn't correct work, because __import__ get module name as first argument, but when we use self.importer we give class instance as first argument.

As result "BaseConfigurator.resolve" (line 178) raise ValueError with message "__import__() argument 1 must be string, not DictConfigurator"

Attachments (1)

importer_patch.diff (925 bytes) - added by Alexandr 7 years ago.
Ticket patch variant

Download all attachments as: .zip

Change History (6)

Changed 7 years ago by Alexandr

Attachment: importer_patch.diff added

Ticket patch variant

comment:1 Changed 7 years ago by Aymeric Augustin

This module is copy-pasted from python 2.7:

It's surprising to find such an obvious mistake in Python itself, and if the bug is confirmed, it should be filed in Python's bug tracker too.

I'm a bit wary of reports based on code inspection; could you explain the situation where you hit this bug?

comment:2 Changed 7 years ago by Alexandr

I tried to debug my django script (use multiprocessing module) with winpdb support.

For test I run command: env/bin/winpdb ./ help

As result I get an error when django load "django.utils.log.CallbackFilter":
ValueError with message "__import__() argument 1 must be string, not DictConfigurator

At line:
variable used = 'django'
but self.importer(used) get self (DictConfigurator) as first argument.

After I patched importer its work well without errors.

comment:3 Changed 7 years ago by Alexandr

Create empty django project: django-admin createproject bbbtest
Create virtualenv with django and winpdb/rpdb2.
Execute env/bin/rpdb2 ./ help
Input "go" several times and you get traceback

Full traceback

/tmp/bbbtest/venv/src/django/django/conf/ DeprecationWarning: The ADMIN_MEDIA_PREFIX setting has been removed; use STATIC_URL instead.
  "use STATIC_URL instead.", DeprecationWarning)
Traceback (most recent call last):
  File "/tmp/bbbtest/venv/lib/python2.6/site-packages/", line 14499, in <module>
    ret = rpdb2.main()
  File "/tmp/bbbtest/venv/lib/python2.6/site-packages/", line 14470, in main
    StartServer(_rpdb2_args, fchdir, _rpdb2_pwd, fAllowUnencrypted, fAllowRemote, secret)
  File "/tmp/bbbtest/venv/lib/python2.6/site-packages/", line 14220, in StartServer
    imp.load_source('__main__', _path)    
  File "/tmp/bbbtest/", line 11, in <module>
  File "/tmp/bbbtest/venv/src/django/django/core/management/", line 442, in execute_manager
  File "/tmp/bbbtest/venv/src/django/django/core/management/", line 368, in execute
    sys.stdout.write(self.main_help_text() + '\n')
  File "/tmp/bbbtest/venv/src/django/django/core/management/", line 239, in main_help_text
    commands = get_commands().keys()
  File "/tmp/bbbtest/venv/src/django/django/core/management/", line 101, in get_commands
    apps = settings.INSTALLED_APPS
  File "/tmp/bbbtest/venv/src/django/django/utils/", line 172, in inner
  File "/tmp/bbbtest/venv/src/django/django/conf/", line 42, in _setup
    self._wrapped = Settings(settings_module)
  File "/tmp/bbbtest/venv/src/django/django/conf/", line 145, in __init__
  File "/tmp/bbbtest/venv/src/django/django/utils/", line 553, in dictConfig
  File "/tmp/bbbtest/venv/src/django/django/utils/", line 339, in configure
    'filter %r: %s' % (name, e))
ValueError: Unable to configure filter 'require_debug_false': __import__() argument 1 must be string, not DictConfigurator

comment:4 Changed 7 years ago by Alexandr

I think rpbd2 replace __import__, and importer begin as class instance method.

comment:5 Changed 7 years ago by Aymeric Augustin

Resolution: invalid
Status: newclosed

So it looks like there's an incompatibility between winpdb/rpdb2 and Python 2.7's logging library, and this incompatibility happens to show up in the copy of the logging library shipped with Django.

In my opinion, if winpdb/rpdb2 isn't compatible with Python's standard library, it's a bug in winpdb/rpdb2, not in Django. Hence, I will mark this ticket as invalid.

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