New submission from panos black:

If you configure logging using a JSON file, then, after you parse it and you 
pass it to logging.config.dictConfig(), you realize that when you define an 
SMTPHandler you can't set "credentials", or, more precisely, whether you set it 
or not the credentials value is ignored.

This happens because SMTPHandler's __init__ has the following code

        if isinstance(credentials, tuple):
            self.username, self.password = credentials
        else:
            self.username = None

while "credentials" inside dictConfig() is a "ConvertingList" and not a 
"tuple". As a result, username is set to None. 

I think that this is a problem because:

a) "credentials" is allowed to be specified in the configuration file (i.e. if 
you have an identifier that SMTPHandler's __init__, knows nothing about then 
you get an exception).
b) Other fields like, "timeout", and "toaddrs" work as expected (i.e. you can 
set them just fine)
c) This behaviour is not documented and you end up with improperly configured 
logging.

I guess that similar problems exist in other handlers too, but I haven't 
checked them one by one.

I think that it would make sense to be able to set all __init__ arguments in 
the Handlers section, or at least, if this is not desirable, to document this 
behaviour.

----------
assignee: docs@python
components: Documentation, Library (Lib)
messages: 229488
nosy: docs@python, panos.black, vinay.sajip
priority: normal
severity: normal
status: open
title: Set SMTPHandler's "credentials" through "logging.config.dictConfig".
type: enhancement
versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22646>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to