Kaydet (Commit) 8188f585 authored tarafından Vinay Sajip's avatar Vinay Sajip

Fixes #12637: Merged fix from 3.2 and added test.

...@@ -1442,7 +1442,8 @@ class Logger(Filterer): ...@@ -1442,7 +1442,8 @@ class Logger(Filterer):
c = c.parent c = c.parent
if (found == 0): if (found == 0):
if lastResort: if lastResort:
lastResort.handle(record) if record.levelno >= lastResort.level:
lastResort.handle(record)
elif raiseExceptions and not self.manager.emittedNoHandlerWarning: elif raiseExceptions and not self.manager.emittedNoHandlerWarning:
sys.stderr.write("No handlers could be found for logger" sys.stderr.write("No handlers could be found for logger"
" \"%s\"\n" % self.name) " \"%s\"\n" % self.name)
......
...@@ -2923,6 +2923,8 @@ class LastResortTest(BaseTest): ...@@ -2923,6 +2923,8 @@ class LastResortTest(BaseTest):
old_raise_exceptions = logging.raiseExceptions old_raise_exceptions = logging.raiseExceptions
try: try:
sys.stderr = sio = io.StringIO() sys.stderr = sio = io.StringIO()
root.debug('This should not appear')
self.assertEqual(sio.getvalue(), '')
root.warning('This is your final chance!') root.warning('This is your final chance!')
self.assertEqual(sio.getvalue(), 'This is your final chance!\n') self.assertEqual(sio.getvalue(), 'This is your final chance!\n')
#No handlers and no last resort, so 'No handlers' message #No handlers and no last resort, so 'No handlers' message
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment