Commit 823830d4 authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab Committed by Greg Kroah-Hartman

docs: kernel_abi.py: fix UTF-8 support

The parser breaks with UTF-8 characters with Sphinx 1.4.
Acked-by: default avatarJonathan Corbet <corbet@lwn.net>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
Link: https://lore.kernel.org/r/9e7c8e3b0efaa1ae0536da6493ab438bd3f9fe58.1604042072.git.mchehab+huawei@kernel.orgSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 9ca876f9
# -*- coding: utf-8; mode: python -*- # -*- coding: utf-8; mode: python -*-
# coding=utf-8
# SPDX-License-Identifier: GPL-2.0 # SPDX-License-Identifier: GPL-2.0
#
u""" u"""
kernel-abi kernel-abi
~~~~~~~~~~ ~~~~~~~~~~
...@@ -30,6 +32,7 @@ u""" ...@@ -30,6 +32,7 @@ u"""
""" """
import codecs
import sys import sys
import os import os
from os import path from os import path
...@@ -45,14 +48,6 @@ from docutils.utils.error_reporting import ErrorString ...@@ -45,14 +48,6 @@ from docutils.utils.error_reporting import ErrorString
__version__ = '1.0' __version__ = '1.0'
# We can't assume that six is installed
PY3 = sys.version_info[0] == 3
PY2 = sys.version_info[0] == 2
if PY3:
# pylint: disable=C0103, W0622
unicode = str
basestring = str
def setup(app): def setup(app):
app.add_directive("kernel-abi", KernelCmd) app.add_directive("kernel-abi", KernelCmd)
...@@ -117,12 +112,12 @@ class KernelCmd(Directive): ...@@ -117,12 +112,12 @@ class KernelCmd(Directive):
cmd cmd
, stdout = subprocess.PIPE , stdout = subprocess.PIPE
, stderr = subprocess.PIPE , stderr = subprocess.PIPE
, universal_newlines = True
, **kwargs , **kwargs
) )
out, err = proc.communicate() out, err = proc.communicate()
if err:
self.warn(err) out, err = codecs.decode(out, 'utf-8'), codecs.decode(err, 'utf-8')
if proc.returncode != 0: if proc.returncode != 0:
raise self.severe( raise self.severe(
u"command '%s' failed with return code %d" u"command '%s' failed with return code %d"
...@@ -131,7 +126,7 @@ class KernelCmd(Directive): ...@@ -131,7 +126,7 @@ class KernelCmd(Directive):
except OSError as exc: except OSError as exc:
raise self.severe(u"problems with '%s' directive: %s." raise self.severe(u"problems with '%s' directive: %s."
% (self.name, ErrorString(exc))) % (self.name, ErrorString(exc)))
return unicode(out) return out
def nestedParse(self, lines, fname): def nestedParse(self, lines, fname):
content = ViewList() content = ViewList()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment