[issue12718] Logical mistake of importer method in logging.config.BaseConfigurator

Vinay Sajip report at bugs.python.org
Wed Aug 10 17:33:06 CEST 2011


Vinay Sajip <vinay_sajip at yahoo.co.uk> added the comment:

@Александр: It still works for me without winpdb/rpdb2, so you should probably report this there. Can you confirm that it works as expected when you do "python manage.py help"?

vinay at eta-natty:/tmp$ virtualenv -p python2.7 bbbenv
Running virtualenv with interpreter /usr/bin/python2.7
New python executable in bbbenv/bin/python2.7
Also creating executable in bbbenv/bin/python
Installing setuptools............................done.
Installing pip...............done.
vinay at eta-natty:/tmp$ source bbbenv/bin/activate
(bbbenv)vinay at eta-natty:/tmp$ easy_install django
Searching for django
Reading http://pypi.python.org/simple/django/
Reading http://www.djangoproject.com/
Best match: Django 1.3
Downloading http://media.djangoproject.com/releases/1.3/Django-1.3.tar.gz
Processing Django-1.3.tar.gz

[output snipped]

Installed /tmp/bbbenv/lib/python2.7/site-packages/Django-1.3-py2.7.egg
Processing dependencies for django
Finished processing dependencies for django
(bbbenv)vinay at eta-natty:/tmp$ django-admin.py startproject bbbtest
(bbbenv)vinay at eta-natty:/tmp$ cd bbbtest
(bbbenv)vinay at eta-natty:/tmp/bbbtest$ python manage.py help
Usage: manage.py subcommand [options] [args]

[output snipped]

(bbbenv)vinay at eta-natty:/tmp/bbbtest$ grep LOGGING_CONFIG settings.py
LOGGING_CONFIG = 'logging.config.dictConfig'

@David: Marking as a static method simply ensures that the attribute is returned as a function, which is already happening:

>>> class C:
...     @staticmethod
...     def func(x): print x
...     def meth(self, x): print x
... 
>>> C.func, C.meth, C().func, C().meth
(<function func at 0xb783ddf4>, <unbound method C.meth>, <function func at 0xb783ddf4>, <bound method C.meth of <__main__.C instance at 0xb75cafcc>>)
>>> import logging.config
>>> DC = logging.config.DictConfigurator
>>> DC.importer, DC.configure, DC({}).importer, DC({}).configure
(<built-in function __import__>, <unbound method DictConfigurator.configure>, <built-in function __import__>, <bound method DictConfigurator.configure of <logging.config.DictConfigurator object at 0xb75b520c>>)

I have no objection to changing things to support PyPy, but what's the idiom? I don't believe importer = staticmethod(__import__) will work here, as it just creates a staticmethod object (which isn't callable).

----------
status: open -> pending

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue12718>
_______________________________________


More information about the Python-bugs-list mailing list