Issue #23207: Improved kwarg validation.
This commit is contained in:
parent
ab6b9f8a5b
commit
d55436ace3
|
@ -1734,8 +1734,8 @@ def basicConfig(**kwargs):
|
|||
"specified together with 'handlers'")
|
||||
if handlers is None:
|
||||
filename = kwargs.pop("filename", None)
|
||||
mode = kwargs.pop("filemode", 'a')
|
||||
if filename:
|
||||
mode = kwargs.pop("filemode", 'a')
|
||||
h = FileHandler(filename, mode)
|
||||
else:
|
||||
stream = kwargs.pop("stream", None)
|
||||
|
|
|
@ -3589,6 +3589,10 @@ class BasicConfigTest(unittest.TestCase):
|
|||
handlers=handlers)
|
||||
assertRaises(ValueError, logging.basicConfig, stream=stream,
|
||||
handlers=handlers)
|
||||
# Issue 23207: test for invalid kwargs
|
||||
assertRaises(ValueError, logging.basicConfig, loglevel=logging.INFO)
|
||||
# Should pop both filename and filemode even if filename is None
|
||||
logging.basicConfig(filename=None, filemode='a')
|
||||
|
||||
def test_handlers(self):
|
||||
handlers = [
|
||||
|
|
Loading…
Reference in New Issue