]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-36272: Logging now propagates RecursionError (GH-12312)
authorRémi Lapeyre <remi.lapeyre@henki.fr>
Fri, 15 Mar 2019 06:53:34 +0000 (07:53 +0100)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Fri, 15 Mar 2019 06:53:34 +0000 (06:53 +0000)
Lib/logging/__init__.py
Lib/test/test_logging.py
Misc/NEWS.d/next/Library/2019-03-13-14-14-36.bpo-36272.f3l2IG.rst [new file with mode: 0644]

index b4659af7cc985f7961b7d30fbc053202d0a32a5e..7355396541a3e9c54dbd6ea93e93fb854e5bc828 100644 (file)
@@ -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)
 
index c797d66aa6452c1d01e8682be7973c595452bf82..b23ae24920b7482ab90b76b28cd82145a74a4d91 100644 (file)
@@ -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):
diff --git a/Misc/NEWS.d/next/Library/2019-03-13-14-14-36.bpo-36272.f3l2IG.rst b/Misc/NEWS.d/next/Library/2019-03-13-14-14-36.bpo-36272.f3l2IG.rst
new file mode 100644 (file)
index 0000000..2f2f790
--- /dev/null
@@ -0,0 +1,2 @@
+:mod:`logging` does not silently ignore RecursionError anymore. Patch
+contributed by Rémi Lapeyre.