[3.8] bpo-42644: Validate values in logging.disable() (GH-23786) #23797
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 ofwarnings.
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 adifferent 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 b32d8b4)
Co-authored-by: Matthias Bussonnier bussonniermatthias@gmail.com
https://bugs.python.org/issue42644