[issue38235] Docs of logging module says argument is named "lvl". TypeError.

New submission from Daniel Andersson <daniel.4ndersson@gmail.com>: 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. ---------- assignee: docs@python components: Documentation, Library (Lib) messages: 352866 nosy: docs@python, penlect, vinay.sajip priority: normal severity: normal status: open title: Docs of logging module says argument is named "lvl". TypeError. versions: Python 2.7, Python 3.5, Python 3.6, Python 3.7, Python 3.8, Python 3.9 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Change by Raymond Hettinger <raymond.hettinger@gmail.com>: ---------- assignee: docs@python -> rhettinger nosy: +rhettinger versions: -Python 3.5, Python 3.6 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Change by AWhetter <ashley@awhetter.co.uk>: ---------- keywords: +patch pull_requests: +16162 stage: -> patch review pull_request: https://github.com/python/cpython/pull/16571 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Change by Raymond Hettinger <raymond.hettinger@gmail.com>: ---------- assignee: rhettinger -> vinay.sajip _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Vinay Sajip <vinay_sajip@yahoo.co.uk> added the comment: New changeset 3142c667b50254daaa28f22c79bdda177136bd03 by Vinay Sajip (Ashley Whetter) in branch 'master': bpo-38235: Correct some arguments names in logging documentation (GH-16571) https://github.com/python/cpython/commit/3142c667b50254daaa28f22c79bdda17713... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +16168 pull_request: https://github.com/python/cpython/pull/16576 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Change by miss-islington <mariatta.wijaya+miss-islington@gmail.com>: ---------- pull_requests: +16169 pull_request: https://github.com/python/cpython/pull/16577 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Vinay Sajip <vinay_sajip@yahoo.co.uk> added the comment: New changeset 3af2733a8265a2685b2c0466a58a66e544a81c64 by Vinay Sajip (Miss Islington (bot)) in branch '3.8': bpo-38235: Correct some arguments names in logging documentation (GH-16571) (GH-16576) https://github.com/python/cpython/commit/3af2733a8265a2685b2c0466a58a66e544a... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Vinay Sajip <vinay_sajip@yahoo.co.uk> added the comment: New changeset 4f82a53c5d34df00bf2d563c2417f5e2638d1004 by Vinay Sajip (Miss Islington (bot)) in branch '3.7': bpo-38235: Correct some arguments names in logging documentation (GH-16571) (GH-16577) https://github.com/python/cpython/commit/4f82a53c5d34df00bf2d563c2417f5e2638... ---------- _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Change by Vinay Sajip <vinay_sajip@yahoo.co.uk>: ---------- resolution: -> fixed stage: patch review -> resolved status: open -> closed versions: -Python 2.7 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Change by AWhetter <ashley@awhetter.co.uk>: ---------- pull_requests: +16177 pull_request: https://github.com/python/cpython/pull/16586 _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________

Ned Deily <nad@python.org> added the comment: New changeset 6eb554583218cda9a145982a41c30612968a942f by Ned Deily (Miss Islington (bot)) in branch '3.7': bpo-38235: Correct some arguments names in logging documentation (GH-16571) (GH-16577) https://github.com/python/cpython/commit/6eb554583218cda9a145982a41c30612968... ---------- nosy: +ned.deily _______________________________________ Python tracker <report@bugs.python.org> <https://bugs.python.org/issue38235> _______________________________________
participants (6)
-
AWhetter
-
Daniel Andersson
-
miss-islington
-
Ned Deily
-
Raymond Hettinger
-
Vinay Sajip