Skip to content

Commit

Permalink
Merge pull request #7441 from tk0miya/7423_logging_non_string_object
Browse files Browse the repository at this point in the history
Fix #7423: crashed when giving a non-string object to logger
  • Loading branch information
tk0miya committed Apr 9, 2020
2 parents b316375 + 5662ece commit 9002b6c
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGES
Expand Up @@ -22,6 +22,7 @@ Bugs fixed
* #7418: std domain: duplication warning for glossary terms is case insensitive
* #7438: C++, fix merging overloaded functions in parallel builds.
* #7422: autodoc: fails with ValueError when using autodoc_mock_imports
* #7423: crashed when giving a non-string object to logger

Testing
--------
Expand Down
2 changes: 1 addition & 1 deletion sphinx/util/logging.py
Expand Up @@ -412,7 +412,7 @@ def filter(self, record: logging.LogRecord) -> bool:
message = record.msg # use record.msg itself

if location:
raise SphinxWarning(location + ":" + message)
raise SphinxWarning(location + ":" + str(message))
else:
raise SphinxWarning(message)
else:
Expand Down
8 changes: 8 additions & 0 deletions tests/test_util_logging.py
Expand Up @@ -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 "<class 'Exception'>" in status.getvalue()


def test_verbosity_filter(app, status, warning):
# verbosity = 0: INFO
app.verbosity = 0
Expand Down

0 comments on commit 9002b6c

Please sign in to comment.