Skip to content

Commit 0e0bdce

Browse files
Jonathan Corbetgregkh
authored andcommitted
docs: kdoc: handle the obsolescensce of docutils.ErrorString()
commit 00d95fc upstream. 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> [ Salvatore Bonaccorso: Backport to v6.17.y for context changes in Documentation/sphinx/kernel_include.py with major refactorings for the v6.18 development cycle. Backport ErrorString definition as well to Documentation/sphinx/kernel_abi.py file for 6.12.y where it is imported from docutils before the faccc0e ("docs: sphinx/kernel_abi: adjust coding style") change. ] Suggested-by: Andreas Radke <andreas.radke@mailbox.org> Signed-off-by: Salvatore Bonaccorso <carnil@debian.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent cc89ac0 commit 0e0bdce

File tree

4 files changed

+13
-5
lines changed

4 files changed

+13
-5
lines changed

Documentation/sphinx/kernel_abi.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,11 @@
4242
from docutils import nodes, statemachine
4343
from docutils.statemachine import ViewList
4444
from docutils.parsers.rst import directives, Directive
45-
from docutils.utils.error_reporting import ErrorString
4645
from sphinx.util.docutils import switch_source_input
4746

47+
def ErrorString(exc): # Shamelessly stolen from docutils
48+
return f'{exc.__class__.__name}: {exc}'
49+
4850
__version__ = '1.0'
4951

5052
def setup(app):

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
@@ -34,13 +34,15 @@
3434
import os.path
3535

3636
from docutils import io, nodes, statemachine
37-
from docutils.utils.error_reporting import SafeString, ErrorString
3837
from docutils.parsers.rst import directives
3938
from docutils.parsers.rst.directives.body import CodeBlock, NumberLines
4039
from docutils.parsers.rst.directives.misc import Include
4140

4241
__version__ = '1.0'
4342

43+
def ErrorString(exc): # Shamelessly stolen from docutils
44+
return f'{exc.__class__.__name}: {exc}'
45+
4446
# ==============================================================================
4547
def setup(app):
4648
# ==============================================================================
@@ -111,7 +113,7 @@ def _run(self):
111113
raise self.severe('Problems with "%s" directive path:\n'
112114
'Cannot encode input file path "%s" '
113115
'(wrong locale?).' %
114-
(self.name, SafeString(path)))
116+
(self.name, path))
115117
except IOError as error:
116118
raise self.severe('Problems with "%s" directive path:\n%s.' %
117119
(self.name, ErrorString(error)))

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)