Skip to content

Commit 823830d

Browse files
mchehabgregkh
authored andcommitted
docs: kernel_abi.py: fix UTF-8 support
The parser breaks with UTF-8 characters with Sphinx 1.4. Acked-by: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Link: https://lore.kernel.org/r/9e7c8e3b0efaa1ae0536da6493ab438bd3f9fe58.1604042072.git.mchehab+huawei@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9ca876f commit 823830d

1 file changed

Lines changed: 7 additions & 12 deletions

File tree

Documentation/sphinx/kernel_abi.py

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# -*- coding: utf-8; mode: python -*-
2+
# coding=utf-8
23
# SPDX-License-Identifier: GPL-2.0
4+
#
35
u"""
46
kernel-abi
57
~~~~~~~~~~
@@ -30,6 +32,7 @@
3032
3133
"""
3234

35+
import codecs
3336
import sys
3437
import os
3538
from os import path
@@ -45,14 +48,6 @@
4548

4649
__version__ = '1.0'
4750

48-
# We can't assume that six is installed
49-
PY3 = sys.version_info[0] == 3
50-
PY2 = sys.version_info[0] == 2
51-
if PY3:
52-
# pylint: disable=C0103, W0622
53-
unicode = str
54-
basestring = str
55-
5651
def setup(app):
5752

5853
app.add_directive("kernel-abi", KernelCmd)
@@ -117,12 +112,12 @@ def runCmd(self, cmd, **kwargs):
117112
cmd
118113
, stdout = subprocess.PIPE
119114
, stderr = subprocess.PIPE
120-
, universal_newlines = True
121115
, **kwargs
122116
)
123117
out, err = proc.communicate()
124-
if err:
125-
self.warn(err)
118+
119+
out, err = codecs.decode(out, 'utf-8'), codecs.decode(err, 'utf-8')
120+
126121
if proc.returncode != 0:
127122
raise self.severe(
128123
u"command '%s' failed with return code %d"
@@ -131,7 +126,7 @@ def runCmd(self, cmd, **kwargs):
131126
except OSError as exc:
132127
raise self.severe(u"problems with '%s' directive: %s."
133128
% (self.name, ErrorString(exc)))
134-
return unicode(out)
129+
return out
135130

136131
def nestedParse(self, lines, fname):
137132
content = ViewList()

0 commit comments

Comments
 (0)