Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba350185 authored by Jani Nikula's avatar Jani Nikula
Browse files

Documentation/sphinx: fix kernel-doc extension on python3



Reconcile differences between python2 and python3 on dealing with
stdout, stderr from Popen. This fixes "name 'unicode' is not defined"
errors on python3. We'll need to try to keep the extension working on
both python-sphinx and python3-sphinx so we don't need two copies.

Reported-and-tested-by: default avatarMarius Vlad <marius.c.vlad@intel.com>
Signed-off-by: default avatarJani Nikula <jani.nikula@intel.com>
parent 2f4ad40a
Loading
Loading
Loading
Loading
+7 −2
Original line number Diff line number Diff line
@@ -23,6 +23,9 @@
#
# Authors:
#    Jani Nikula <jani.nikula@intel.com>
#
# Please make sure this works on both python2 and python3.
#

import os
import subprocess
@@ -75,7 +78,9 @@ class KernelDocDirective(Directive):
            p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
            out, err = p.communicate()

            # assume the kernel sources are utf-8
            # python2 needs conversion to unicode.
            # python3 with universal_newlines=True returns strings.
            if sys.version_info.major < 3:
                out, err = unicode(out, 'utf-8'), unicode(err, 'utf-8')

            if p.returncode != 0: