classification
Title: logging.basicConfig does not validate keyword arguments
Type: behavior Stage: resolved
Components: Versions: Python 3.4
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Jeremy Goss, The Compiler, python-dev, vinay.sajip
Priority: normal Keywords:

Created on 2015-01-09 14:20 by The Compiler, last changed 2015-03-18 08:50 by python-dev. This issue is now closed.

Messages (4)
msg233756 - (view) Author: Florian Bruhin (The Compiler) Date: 2015-01-09 14:20
logging.basicConfig uses **kwargs and does not validate them.

This caused me to shoot myself in the foot multiple times by passing logLevel instead of level accidentally, and then trying to figure out why my messages don't get logged.
msg234574 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-01-23 19:54
New changeset 2bc3e839a3a3 by Vinay Sajip in branch '3.4':
Issue #23207: logging.basicConfig() now does additional validation of its arguments.
https://hg.python.org/cpython/rev/2bc3e839a3a3

New changeset 06ba5e776a6e by Vinay Sajip in branch 'default':
Closes #23207: logging.basicConfig() now does additional validation of its arguments.
https://hg.python.org/cpython/rev/06ba5e776a6e
msg238374 - (view) Author: Jeremy Goss (Jeremy Goss) Date: 2015-03-18 03:29
The argument validation in basicConfig has introduced another problem.
I cannot pass in an optional filename/filemode argument pair.

Previously, I passed in an optional logfile argument from ArgumentParser (which could be None). Now, I get a ValueError because filemode is not popped if filename is None.

logging.basicConfig(..., filename=args.logfile, filemode="w")
...
ValueError: Unrecognised argument(s): filemode

Suggested fix to place mode assignment alongside filename in basicConfig():
    filename = kwargs.pop("filename", None)
    mode = kwargs.pop("filemode", 'a')
    if filename:
        h = FileHandler(filename, mode)
msg238382 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-03-18 08:50
New changeset d3b420807a86 by Vinay Sajip in branch '3.4':
Issue #23207: Improved kwarg validation.
https://hg.python.org/cpython/rev/d3b420807a86

New changeset 7ff0d7b50b36 by Vinay Sajip in branch 'default':
Issue #23207: merged fix from 3.4.
https://hg.python.org/cpython/rev/7ff0d7b50b36
History
Date User Action Args
2015-03-18 08:50:09python-devsetmessages: + msg238382
2015-03-18 03:29:29Jeremy Gosssetnosy: + Jeremy Goss
messages: + msg238374
2015-01-23 19:54:48python-devsetstatus: open -> closed

nosy: + python-dev
messages: + msg234574

resolution: fixed
stage: resolved
2015-01-09 14:20:39The Compilercreate