Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d55436a

Browse files
committed
Issue #23207: Improved kwarg validation.
1 parent ab6b9f8 commit d55436a

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

Lib/logging/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1734,8 +1734,8 @@ def basicConfig(**kwargs):
17341734
"specified together with 'handlers'")
17351735
if handlers is None:
17361736
filename = kwargs.pop("filename", None)
1737+
mode = kwargs.pop("filemode", 'a')
17371738
if filename:
1738-
mode = kwargs.pop("filemode", 'a')
17391739
h = FileHandler(filename, mode)
17401740
else:
17411741
stream = kwargs.pop("stream", None)

Lib/test/test_logging.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3589,6 +3589,10 @@ def test_incompatible(self):
35893589
handlers=handlers)
35903590
assertRaises(ValueError, logging.basicConfig, stream=stream,
35913591
handlers=handlers)
3592+
# Issue 23207: test for invalid kwargs
3593+
assertRaises(ValueError, logging.basicConfig, loglevel=logging.INFO)
3594+
# Should pop both filename and filemode even if filename is None
3595+
logging.basicConfig(filename=None, filemode='a')
35923596

35933597
def test_handlers(self):
35943598
handlers = [

0 commit comments

Comments
 (0)