mirror of
https://github.com/python/cpython.git
synced 2025-07-24 11:44:31 +00:00
bpo-42644: Validate values in logging.disable() (#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>
This commit is contained in:
parent
3f9fe23c05
commit
b32d8b4f9b
3 changed files with 20 additions and 0 deletions
|
@ -1289,6 +1289,14 @@ class Manager(object):
|
|||
self.loggerClass = None
|
||||
self.logRecordFactory = None
|
||||
|
||||
@property
|
||||
def disable(self):
|
||||
return self._disable
|
||||
|
||||
@disable.setter
|
||||
def disable(self, value):
|
||||
self._disable = _checkLevel(value)
|
||||
|
||||
def getLogger(self, name):
|
||||
"""
|
||||
Get a logger with the specified name (channel name), creating it
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue