This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Set SMTPHandler's "credentials" through "logging.config.dictConfig".
Type: enhancement Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: vinay.sajip Nosy List: docs@python, panos.black, python-dev, vinay.sajip
Priority: normal Keywords:

Created on 2014-10-15 18:09 by panos.black, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Messages (2)
msg229488 - (view) Author: panos black (panos.black) Date: 2014-10-15 18:09
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.
msg229568 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-10-17 07:52
New changeset 3ba23c6f7986 by Vinay Sajip in branch '2.7':
Issue #22646: Accept list as well as tuple to support initialisation via dictConfig().
https://hg.python.org/cpython/rev/3ba23c6f7986

New changeset d15708f13266 by Vinay Sajip in branch '3.4':
Issue #22646: Accept list as well as tuple to support initialisation via dictConfig().
https://hg.python.org/cpython/rev/d15708f13266

New changeset bcc3f167a30b by Vinay Sajip in branch 'default':
Closes #22646: Accept list as well as tuple to support initialisation via dictConfig().
https://hg.python.org/cpython/rev/bcc3f167a30b
History
Date User Action Args
2022-04-11 14:58:09adminsetgithub: 66836
2014-10-17 07:52:39python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg229568

resolution: fixed
stage: resolved
2014-10-15 21:52:25vinay.sajipsetassignee: docs@python -> vinay.sajip
versions: - Python 3.2, Python 3.3
2014-10-15 18:09:30panos.blackcreate