Fix #4070: crashes when the warning message contains format strings

This commit is contained in:
Takeshi KOMIYA 2017-09-24 13:52:59 +09:00
parent 6b7e33a332
commit a455ffcce1
2 changed files with 4 additions and 2 deletions

View File

@ -34,6 +34,7 @@ Bugs fixed
* #4049: Fix typo in output of sphinx-build -h
* #4062: hashlib.sha1() must take bytes, not unicode on Python 3
* Avoid indent after index entries in latex (refs: #4066)
* #4070: crashes when the warning message contains format strings
Testing

View File

@ -356,10 +356,11 @@ class WarningIsErrorFilter(logging.Filter):
return True
elif self.app.warningiserror:
location = getattr(record, 'location', '')
message = record.msg.replace('%', '%%')
if location:
raise SphinxWarning(location + ":" + record.msg % record.args)
raise SphinxWarning(location + ":" + message % record.args)
else:
raise SphinxWarning(record.msg % record.args)
raise SphinxWarning(message % record.args)
else:
return True