[docs] [issue22646] Set SMTPHandler's "credentials" through "logging.config.dictConfig".

panos black report at bugs.python.org
Wed Oct 15 20:09:30 CEST 2014

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
            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 at python
components: Documentation, Library (Lib)
messages: 229488
nosy: docs at 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 <report at bugs.python.org>

More information about the docs mailing list