From 44012c032bd53fd92543aa374cb974dc33eafc88 Mon Sep 17 00:00:00 2001 From: Ian Wienand Date: Mon, 2 Jul 2018 17:27:21 +1000 Subject: [PATCH] Open role readme files in utf-8 mode I managed to get some hidden utf-8 characters into a zuul role README.rst file which broke building in the gate on python 2.7 in a rather mysterious way, deep inside the rst parser. Make sure we open the README.rst files in unicode mode; this way the lines are passed into the rst core as unicode and things go as planned. Change-Id: Id27062989c0527de545b18471eec29926955a4e4 --- zuul_sphinx/zuul.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/zuul_sphinx/zuul.py b/zuul_sphinx/zuul.py index a140988..7e8463a 100644 --- a/zuul_sphinx/zuul.py +++ b/zuul_sphinx/zuul.py @@ -13,6 +13,7 @@ # under the License. from collections import OrderedDict +import codecs import os from sphinx import addnodes @@ -187,7 +188,7 @@ class ZuulDirective(Directive): lines.append('.. zuul:role:: %s' % name) lines.append('') role_readme = self.zuul_role_paths[name] - with open(role_readme) as f: + with codecs.open(role_readme, encoding='utf-8') as f: role_lines = f.read().split('\n') for l in role_lines: lines.append(' ' + l)