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.

Author penlect
Recipients docs@python, penlect, vinay.sajip
Date 2019-09-20.16:26:57
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1568996817.83.0.32795106699.issue38235@roundup.psfhosted.org>
In-reply-to
Content
How to reproduce:

>>> import logging
>>> logging.disable(lvl=logging.ERROR)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: disable() got an unexpected keyword argument 'lvl'

The correct keyword argument name is `level` as can be seen in the Python code Lib/logging/__init__.py:
---> def disable(level=CRITICAL):

The documentation uses `lvl`, see Doc/library/logging.rst:
---> .. function:: disable(lvl=CRITICAL)

The solution would be to rename the argument from `lvl` to `level` in the documentation.

I also noticed some more cases in the logging module docs where `lvl` is used (and `level` is used in the Python code):

* logging.Logger.isEnabledFor(lvl)
* logging.Logger.log(lvl, msg, *args, **kwargs)
* logging.Logger.makeRecord(name, lvl, fn, lno, msg, args, exc_info, func=None, extra=None, sinfo=None)
* logging.addLevelName(lvl, levelName)
* logging.getLevelName(lvl)

Maybe there are some historical reasons for this that I'm not aware about.

I also found an inconsistency. In the `Handler` class the docs does use `level`:
* logging.Handler.setLevel(level)

I can understand that the English in the documentation might be clearer when written as:
"Associates level `lvl` with text `levelName`"
instead of,
"Associates level `level` with text `levelName`"
- avoids the double-"level".

But at the same time, I usually trust the documentation blindly and was surprised by this error.

In the five listed examples above, `lvl` is only used as a positional argument. Maybe it is more OK to deviate from the actual name in the code in this case compared to keyword arguments, as in logging.disable.
History
Date User Action Args
2019-09-20 16:26:57penlectsetrecipients: + penlect, vinay.sajip, docs@python
2019-09-20 16:26:57penlectsetmessageid: <1568996817.83.0.32795106699.issue38235@roundup.psfhosted.org>
2019-09-20 16:26:57penlectlinkissue38235 messages
2019-09-20 16:26:57penlectcreate