classification
Title: LogRecord attributes are not tuple, when logging only dict
Type: Stage: resolved
Components: Versions: Python 3.4, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: python-dev, r.david.murray, sejvlond, vinay.sajip
Priority: normal Keywords:

Created on 2015-10-29 10:22 by sejvlond, last changed 2015-11-24 23:24 by python-dev. This issue is now closed.

Messages (3)
msg253673 - (view) Author: Ondrej Sejvl (sejvlond) Date: 2015-10-29 10:22
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'>
```
msg253676 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2015-10-29 14:36
I believe this is due to the way % formatting works, and so is a doc bug.  Vinay will know for sure, of course :)
msg255303 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-11-24 23:24
New changeset a365fb0dd5e1 by Vinay Sajip in branch '2.7':
Issue #25508: Clarify documentation on LogRecord args attribute.
https://hg.python.org/cpython/rev/a365fb0dd5e1

New changeset 01998efb605a by Vinay Sajip in branch '3.4':
Issue #25508: Clarify documentation on LogRecord args attribute.
https://hg.python.org/cpython/rev/01998efb605a

New changeset ca512b568368 by Vinay Sajip in branch '3.5':
Issue #25508: Merged documentation fix from 3.4.
https://hg.python.org/cpython/rev/ca512b568368

New changeset 1da622f4630b by Vinay Sajip in branch 'default':
Closes #25508: Merged documentation fix from 3.5.
https://hg.python.org/cpython/rev/1da622f4630b
History
Date User Action Args
2015-11-24 23:24:33python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg255303

resolution: fixed
stage: resolved
2015-10-29 14:36:26r.david.murraysetnosy: + vinay.sajip, r.david.murray
messages: + msg253676
2015-10-29 10:22:02sejvlondcreate