Skip to content

Commit 00d95fc

Browse files
author
Jonathan Corbet
committed
docs: kdoc: handle the obsolescensce of docutils.ErrorString()
The ErrorString() and SafeString() docutils functions were helpers meant to ease the handling of encodings during the Python 3 transition. There is no real need for them after Python 3.6, and docutils 0.22 removes them, breaking the docs build Handle this by just injecting our own one-liner version of ErrorString(), and removing the sole SafeString() call entirely. Reported-by: Zhixu Liu <zhixu.liu@gmail.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <87ldmnv2pi.fsf@trenco.lwn.net>
1 parent 944df7a commit 00d95fc

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

Documentation/sphinx/kernel_feat.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@
4040
from docutils import nodes, statemachine
4141
from docutils.statemachine import ViewList
4242
from docutils.parsers.rst import directives, Directive
43-
from docutils.utils.error_reporting import ErrorString
4443
from sphinx.util.docutils import switch_source_input
4544

45+
def ErrorString(exc): # Shamelessly stolen from docutils
46+
return f'{exc.__class__.__name}: {exc}'
47+
4648
__version__ = '1.0'
4749

4850
def setup(app):

Documentation/sphinx/kernel_include.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@
8989

9090
from docutils import io, nodes, statemachine
9191
from docutils.statemachine import ViewList
92-
from docutils.utils.error_reporting import SafeString, ErrorString
9392
from docutils.parsers.rst import Directive, directives
9493
from docutils.parsers.rst.directives.body import CodeBlock, NumberLines
9594

@@ -106,6 +105,9 @@
106105
RE_DOMAIN_REF = re.compile(r'\\ :(ref|c:type|c:func):`([^<`]+)(?:<([^>]+)>)?`\\')
107106
RE_SIMPLE_REF = re.compile(r'`([^`]+)`')
108107

108+
def ErrorString(exc): # Shamelessly stolen from docutils
109+
return f'{exc.__class__.__name}: {exc}'
110+
109111

110112
# ==============================================================================
111113
class KernelInclude(Directive):
@@ -156,7 +158,7 @@ def read_rawtext(self, path, encoding):
156158
except UnicodeEncodeError:
157159
raise self.severe('Problems with directive path:\n'
158160
'Cannot encode input file path "%s" '
159-
'(wrong locale?).' % SafeString(path))
161+
'(wrong locale?).' % path)
160162
except IOError as error:
161163
raise self.severe('Problems with directive path:\n%s.' % ErrorString(error))
162164

Documentation/sphinx/maintainers_include.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,12 @@
2222
import os.path
2323

2424
from docutils import statemachine
25-
from docutils.utils.error_reporting import ErrorString
2625
from docutils.parsers.rst import Directive
2726
from docutils.parsers.rst.directives.misc import Include
2827

28+
def ErrorString(exc): # Shamelessly stolen from docutils
29+
return f'{exc.__class__.__name}: {exc}'
30+
2931
__version__ = '1.0'
3032

3133
def setup(app):

0 commit comments

Comments
 (0)