Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C/C++, fix lack of error stringification #7437

Conversation

jakobandersen
Copy link
Contributor

Feature or Bugfix

  • Bugfix

Purpose

The switch to the new'ish logging facilities in the C and C++ domains was not quite correct. In a few places the logged exception was not stringified.

Detail

@tk0miya
Copy link
Member

tk0miya commented Apr 8, 2020

I consider this is a bug of our logging module. So the following fix is better to me:

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:

What do you think?

@jakobandersen
Copy link
Contributor Author

I looked a bit more into it, and it looks like the fix of @tk0miya is indeed the proper one.
While the top-level functions of the Python logging module definitely says
The documentation of the Python logging module says the first argument must be a format string (https://docs.python.org/3/library/logging.html#logging.debug), but that seems to be incorrect (https://docs.python.org/3/library/logging.html#logging.LogRecord.getMessage).
@tk0miya, do you your fix ready? otherwise I can make a new PR.

@tk0miya
Copy link
Member

tk0miya commented Apr 8, 2020

Okay, I'll do it later.

@jakobandersen jakobandersen deleted the 7423_error_stringification branch April 9, 2020 08:07
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 1, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants