Skip to content

Commit

Permalink
Merge pull request sphinx-doc#4704 from tk0miya/dont_stringify_except…
Browse files Browse the repository at this point in the history
…ions

Use "%r" to stringify exceptions
  • Loading branch information
tk0miya authored Mar 6, 2018
2 parents f89c7f3 95b53a6 commit 65e41f7
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
5 changes: 3 additions & 2 deletions sphinx/directives/code.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 15,7 @@
from docutils import nodes
from docutils.parsers.rst import Directive, directives
from docutils.statemachine import ViewList
from six import text_type

from sphinx import addnodes
from sphinx.locale import __
Expand Down Expand Up @@ -159,7 160,7 @@ def run(self):
try:
literal = container_wrapper(self, literal, caption)
except ValueError as exc:
return [document.reporter.warning(str(exc), line=self.lineno)]
return [document.reporter.warning(text_type(exc), line=self.lineno)]

# literal will be note_implicit_target that is linked from caption and numref.
# when options['name'] is provided, it should be primary ID.
Expand Down Expand Up @@ -456,7 457,7 @@ def run(self):

return [retnode]
except Exception as exc:
return [document.reporter.warning(str(exc), line=self.lineno)]
return [document.reporter.warning(text_type(exc), line=self.lineno)]


def setup(app):
Expand Down
4 changes: 3 additions & 1 deletion sphinx/environment/collectors/indexentries.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 11,8 @@

from typing import TYPE_CHECKING

from six import text_type

from sphinx import addnodes
from sphinx.environment.collectors import EnvironmentCollector
from sphinx.util import split_index_msg, logging
Expand Down Expand Up @@ -45,7 47,7 @@ def process_doc(self, app, doctree):
for entry in node['entries']:
split_index_msg(entry[0], entry[1])
except ValueError as exc:
logger.warning(str(exc), location=node)
logger.warning(text_type(exc), location=node)
node.parent.remove(node)
else:
for entry in node['entries']:
Expand Down
6 changes: 3 additions & 3 deletions sphinx/ext/graphviz.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 277,7 @@ def render_dot_html(self, node, code, options, prefix='graphviz',
"'svg', but is %r") % format)
fname, outfn = render_dot(self, code, options, format, prefix)
except GraphvizError as exc:
logger.warning(__('dot code %r: ') % code str(exc))
logger.warning(__('dot code %r: %s'), code, text_type(exc))
raise nodes.SkipNode

if fname is None:
Expand Down Expand Up @@ -321,7 321,7 @@ def render_dot_latex(self, node, code, options, prefix='graphviz'):
try:
fname, outfn = render_dot(self, code, options, 'pdf', prefix)
except GraphvizError as exc:
logger.warning(__('dot code %r: ') % code str(exc))
logger.warning(__('dot code %r: %s'), code, text_type(exc))
raise nodes.SkipNode

is_inline = self.is_inline(node)
Expand Down Expand Up @@ -359,7 359,7 @@ def render_dot_texinfo(self, node, code, options, prefix='graphviz'):
try:
fname, outfn = render_dot(self, code, options, 'png', prefix)
except GraphvizError as exc:
logger.warning(__('dot code %r: ') % code str(exc))
logger.warning(__('dot code %r: %s'), code, text_type(exc))
raise nodes.SkipNode
if fname is not None:
self.body.append('@image{%s,,,[graphviz],png}\n' % fname[:-4])
Expand Down

0 comments on commit 65e41f7

Please sign in to comment.