diff options
author | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-03-03 02:38:29 +0900 |
---|---|---|
committer | Takeshi KOMIYA <i.tkomiya@gmail.com> | 2018-03-03 23:25:58 +0900 |
commit | 84c475b490e62e07a920d2e67497c51073b29bce (patch) | |
tree | b0e98555593a4340df272514da363d3f5dddab5b /sphinx/directives/code.py | |
parent | 1f5b40c291fc9cc16c323ef6aa4cd417b929bf0f (diff) | |
download | sphinx-git-84c475b490e62e07a920d2e67497c51073b29bce.tar.gz |
Use six.text_type to stringify exceptions
On py2, an exception having i18nized message causes UnicodeError on
stringify. This uses ``six.text_type()`` to stringify them instead.
Diffstat (limited to 'sphinx/directives/code.py')
-rw-r--r-- | sphinx/directives/code.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/sphinx/directives/code.py b/sphinx/directives/code.py index 51abc252b..48d87fb93 100644 --- a/sphinx/directives/code.py +++ b/sphinx/directives/code.py @@ -15,6 +15,7 @@ from typing import TYPE_CHECKING 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 __ @@ -159,7 +160,7 @@ class CodeBlock(Directive): 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. @@ -456,7 +457,7 @@ class LiteralInclude(Directive): 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): |