Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions 4 Lib/logging/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -934,6 +934,8 @@ def handleError(self, record):
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'
Expand Down Expand Up @@ -996,6 +998,8 @@ def emit(self, record):
stream.write(msg)
stream.write(self.terminator)
self.flush()
except RecursionError: # See issue 36272
raise
except Exception:
self.handleError(record)

Expand Down
17 changes: 16 additions & 1 deletion 17 Lib/test/test_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
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 time
Expand Down Expand Up @@ -3699,6 +3699,21 @@ def __del__(self):
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):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
:mod:`logging` does not silently ignore RecursionError anymore. Patch
contributed by Rémi Lapeyre.
Morty Proxy This is a proxified and sanitized view of the page, visit original site.