[New-bugs-announce] [issue25508] LogRecord attributes are not tuple, when logging only dict

Ondrej Sejvl report at bugs.python.org
Thu Oct 29 06:22:02 EDT 2015


New submission from Ondrej Sejvl:

Hi,

in doc https://docs.python.org/3.4/library/logging.html#logrecord-attributes there is
args 	You shouldn’t need to format this yourself. 	The tuple of arguments merged into msg to produce message.

But when I log message with 1 arg - a dict - in record.args will be this dict

```
import logging

class H(logging.Handler):
    def emit(self, record):
        print(record.args, type(record.args))

lgr = logging.getLogger()
lgr.addHandler(H())
lgr.error("msg", 1)
lgr.error("msg", dict(a=1))
lgr.error("msg", dict(a=1), 2)
```
output:
```
(1,) <class 'tuple'>
{'a': 1} <class 'dict'>
({'a': 1}, 2) <class 'tuple'>
```

----------
messages: 253673
nosy: sejvlond
priority: normal
severity: normal
status: open
title: LogRecord attributes are not tuple, when logging only dict
versions: Python 2.7, Python 3.4

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


More information about the New-bugs-announce mailing list