Kaydet (Commit) 65f64b19 authored tarafından Rémi Lapeyre's avatar Rémi Lapeyre Kaydeden (comit) Vinay Sajip

bpo-36272: Logging now propagates RecursionError (GH-12312)

üst 1c668d16
......@@ -1032,6 +1032,8 @@ class Handler(Filterer):
sys.stderr.write('Message: %r\n'
'Arguments: %s\n' % (record.msg,
record.args))
except RecursionError: # See issue 36272
raise
except Exception:
sys.stderr.write('Unable to print the message and arguments'
' - possible formatting error.\nUse the'
......@@ -1094,6 +1096,8 @@ class StreamHandler(Handler):
# issue 35046: merged two stream.writes into one.
stream.write(msg + self.terminator)
self.flush()
except RecursionError: # See issue 36272
raise
except Exception:
self.handleError(record)
......
......@@ -41,7 +41,7 @@ import socket
import struct
import sys
import tempfile
from test.support.script_helper import assert_python_ok
from test.support.script_helper import assert_python_ok, assert_python_failure
from test import support
import textwrap
import threading
......@@ -4142,6 +4142,21 @@ class ModuleLevelMiscTest(BaseTest):
self.assertIn("exception in __del__", err)
self.assertIn("ValueError: some error", err)
def test_recursion_error(self):
# Issue 36272
code = """if 1:
import logging
def rec():
logging.error("foo")
rec()
rec()"""
rc, out, err = assert_python_failure("-c", code)
err = err.decode()
self.assertNotIn("Cannot recover from stack overflow.", err)
self.assertEqual(rc, 1)
class LogRecordTest(BaseTest):
def test_str_rep(self):
......
:mod:`logging` does not silently ignore RecursionError anymore. Patch
contributed by Rémi Lapeyre.
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