From 1ca220762b7d13697d9c8354db80493322f724d8 Mon Sep 17 00:00:00 2001 From: Takeshi KOMIYA Date: Thu, 9 Apr 2020 00:17:35 +0900 Subject: [PATCH] Fix #7423: crashed when giving a non-string object to logger --- CHANGES | 2 ++ sphinx/util/logging.py | 2 +- tests/test_util_logging.py | 8 ++++++++ 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CHANGES b/CHANGES index 212f4571f..810f2ed22 100644 --- a/CHANGES +++ b/CHANGES @@ -16,6 +16,8 @@ Features added Bugs fixed ---------- +* #7423: crashed when giving a non-string object to logger + Testing -------- diff --git a/sphinx/util/logging.py b/sphinx/util/logging.py index fbf161ec0..53053faaf 100644 --- a/sphinx/util/logging.py +++ b/sphinx/util/logging.py @@ -412,7 +412,7 @@ class WarningIsErrorFilter(logging.Filter): message = record.msg # use record.msg itself if location: - raise SphinxWarning(location + ":" + message) + raise SphinxWarning(location + ":" + str(message)) else: raise SphinxWarning(message) else: diff --git a/tests/test_util_logging.py b/tests/test_util_logging.py index 337782d87..36034cd92 100644 --- a/tests/test_util_logging.py +++ b/tests/test_util_logging.py @@ -48,6 +48,14 @@ def test_info_and_warning(app, status, warning): assert 'message5' in warning.getvalue() +def test_Exception(app, status, warning): + logging.setup(app, status, warning) + logger = logging.getLogger(__name__) + + logger.info(Exception) + assert "" in status.getvalue() + + def test_verbosity_filter(app, status, warning): # verbosity = 0: INFO app.verbosity = 0