[issue39142] logging.config.dictConfig will convert namedtuple to ConvertingTuple

Henrique report at bugs.python.org
Sat Dec 28 10:48:23 EST 2019


Henrique <coura.henrique at gmail.com> added the comment:

Sorry for not sending a proper reproducible script when submitting the issue. End of the day and quite frustrated with the bug, anyway, I attached a full script that will show the error.

This is the custom handler I used:

class MyHandler(logging.StreamHandler):
    def __init__(self, resource, *args, **kwargs):
        super().__init__(*args, **kwargs)
        self.resource: namedtuple = resource
    
    def emit(self, record):
        record.msg += f" {self.resource.type}"
        return super().emit(record)


self.resource.type will throw and AttributeError when logging, because resource gets converted from a namedtuple to a ConvertingTuple.

----------
Added file: https://bugs.python.org/file48806/bug.py

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue39142>
_______________________________________


More information about the Python-bugs-list mailing list