]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-42644: Validate values in logging.disable() (GH-23786)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Wed, 16 Dec 2020 10:12:08 +0000 (02:12 -0800)
committerGitHub <noreply@github.com>
Wed, 16 Dec 2020 10:12:08 +0000 (02:12 -0800)
commitdb63da7e5d4a98925a04f903a19bf3595b9c2c46
treea92d6df424a287c7da230429f37d63d68fded0be
parent28bf6ab61f77c69b732a211c398ac882bf3f65f4
bpo-42644: Validate values in logging.disable() (GH-23786)

* bpo-42644: Validate values in logging.disable()

Technically make the value of manager a property that checks and convert
values assigned to it properly. This has the side effect of making
`logging.disable` also accept strings representing the various level of
warnings.

We want to validate the type of the disable attribute at assignment
time, as it is later compared to other levels when emitting warnings and
would generate a `TypeError: '>=' not supported between ....` in a
different part of the code base, which can make it difficult to track
down.

When assigned an incorrect value; it will raise a TypeError when the
wrong type, or ValueError if an invalid str.

Co-authored-by: Andrew Svetlov <andrew.svetlov@gmail.com>
(cherry picked from commit b32d8b4f9bcd2e7d11240b6b9de0262cf8f5e09d)

Co-authored-by: Matthias Bussonnier <bussonniermatthias@gmail.com>
Lib/logging/__init__.py
Lib/test/test_logging.py
Misc/NEWS.d/next/Library/2020-12-15-10-00-04.bpo-42644.XgLCNx.rst [new file with mode: 0644]