[PATCH] docs: make maintainers_include work with Python 2
From: Jonathan Corbet
Date: Tue Oct 01 2019 - 13:26:20 EST
The MAINTAINERS file contains UTF-8 data, so Python 2 code has to be
explicit about moving it into the Unicode realm. Explicitly decode all
data from the file as soon as we read it.
This hack can go away once we deprecate Python 2 support.
Signed-off-by: Jonathan Corbet <corbet@xxxxxxx>
---
Documentation/sphinx/maintainers_include.py | 3 +++
1 file changed, 3 insertions(+)
diff --git a/Documentation/sphinx/maintainers_include.py b/Documentation/sphinx/maintainers_include.py
index de62dd3dabd5..705ba9fd5336 100755
--- a/Documentation/sphinx/maintainers_include.py
+++ b/Documentation/sphinx/maintainers_include.py
@@ -19,6 +19,7 @@ u"""
import re
import os.path
+import sys
from docutils import statemachine
from docutils.utils.error_reporting import ErrorString
@@ -60,6 +61,8 @@ class MaintainersInclude(Include):
field_content = ""
for line in open(path):
+ if sys.version_info.major == 2:
+ line = unicode(line, 'utf-8')
# Have we reached the end of the preformatted Descriptions text?
if descriptions and line.startswith('Maintainers'):
descriptions = False
--
2.21.0