mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
This commit is contained in:
parent
4dc46350a7
commit
50640b700b
1
CHANGES
1
CHANGES
@ -22,6 +22,7 @@ Bugs fixed
|
||||
* #4100: Remove debug print from autodoc extension
|
||||
* #3987: Changing theme from alabaster causes HTML build to fail
|
||||
* #4096: C++, don't crash when using the wrong role type. Thanks to mitya57.
|
||||
* #4070, #4111: crashes when the warning message contains format strings (again)
|
||||
|
||||
Testing
|
||||
--------
|
||||
|
@ -356,11 +356,15 @@ class WarningIsErrorFilter(logging.Filter):
|
||||
return True
|
||||
elif self.app.warningiserror:
|
||||
location = getattr(record, 'location', '')
|
||||
message = record.msg.replace('%', '%%')
|
||||
try:
|
||||
message = record.msg % record.args
|
||||
except TypeError:
|
||||
message = record.msg # use record.msg itself
|
||||
|
||||
if location:
|
||||
raise SphinxWarning(location + ":" + message % record.args)
|
||||
raise SphinxWarning(location + ":" + message)
|
||||
else:
|
||||
raise SphinxWarning(message % record.args)
|
||||
raise SphinxWarning(message)
|
||||
else:
|
||||
return True
|
||||
|
||||
|
@ -165,7 +165,11 @@ def test_warningiserror(app, status, warning):
|
||||
# if True, warning raises SphinxWarning exception
|
||||
app.warningiserror = True
|
||||
with pytest.raises(SphinxWarning):
|
||||
logger.warning('message')
|
||||
logger.warning('message: %s', 'arg')
|
||||
|
||||
# message contains format string (refs: #4070)
|
||||
with pytest.raises(SphinxWarning):
|
||||
logger.warning('%s')
|
||||
|
||||
|
||||
def test_warning_location(app, status, warning):
|
||||
|
Loading…
Reference in New Issue
Block a user