mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-06 21:59:54 -06:00
Utilities/Sphinx: Avoid deprecated docutils error handling helpers
The `SafeString` and `ErrorString` classes are deprecated and will be removed in Docutils 0.21 or later. They help avoid encoding errors during exception handling in Python <= 2.7, but these days we always use Python 3 to build the documentation, at least during development, when error cases are most likely to occur. Fixes: #24039
This commit is contained in:
@@ -59,12 +59,6 @@ CMakeLexer.tokens["root"] = [
|
||||
|
||||
from docutils.parsers.rst import Directive, directives
|
||||
from docutils.transforms import Transform
|
||||
try:
|
||||
from docutils.utils.error_reporting import SafeString, ErrorString
|
||||
except ImportError:
|
||||
# error_reporting was not in utils before version 0.11:
|
||||
from docutils.error_reporting import SafeString, ErrorString
|
||||
|
||||
from docutils import io, nodes
|
||||
|
||||
from sphinx.directives import ObjectDescription
|
||||
@@ -130,13 +124,13 @@ class CMakeModule(Directive):
|
||||
f = io.FileInput(source_path=path, encoding=encoding,
|
||||
error_handler=e_handler)
|
||||
except UnicodeEncodeError as error:
|
||||
raise self.severe('Problems with "%s" directive path:\n'
|
||||
'Cannot encode input file path "%s" '
|
||||
'(wrong locale?).' %
|
||||
(self.name, SafeString(path)))
|
||||
msg = ('Problems with "%s" directive path:\n'
|
||||
'Cannot encode input file path "%s" '
|
||||
'(wrong locale?).' % (self.name, path))
|
||||
raise self.severe(msg)
|
||||
except IOError as error:
|
||||
raise self.severe('Problems with "%s" directive path:\n%s.' %
|
||||
(self.name, ErrorString(error)))
|
||||
msg = 'Problems with "%s" directive path:\n%s.' % (self.name, error)
|
||||
raise self.severe(msg)
|
||||
raw_lines = f.read().splitlines()
|
||||
f.close()
|
||||
rst = None
|
||||
|
||||
Reference in New Issue
Block a user