Skip to content

Commit

Permalink
Fix sphinx-doc#4070: crashes when the warning message contains format…
Browse files Browse the repository at this point in the history
… strings
  • Loading branch information
tk0miya committed Sep 24, 2017
1 parent 6b7e33a commit a455ffc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions sphinx/util/logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,11 @@ def filter(self, record):
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

Expand Down

0 comments on commit a455ffc

Please sign in to comment.