[py3] Open rst file in text mode in wdoc view
Otherwise, UStringIO complains that it receives bytes.
--- a/cubicweb/web/views/wdoc.py Thu Jun 28 11:11:10 2018 +0200
+++ b/cubicweb/web/views/wdoc.py Thu Jun 28 10:06:26 2018 +0200
@@ -21,6 +21,7 @@
"""
+import io
from itertools import chain
from os.path import join
from xml.etree.ElementTree import parse
@@ -132,8 +133,8 @@
self.navigation_links(node)
self.w(u'<div class="hr"></div>')
self.w(u'<h1>%s</h1>' % (title_for_lang(node, self._cw.lang)))
- data = open(join(resourcedir, rid)).read()
- self.w(rest_publish(self, data))
+ with io.open(join(resourcedir, rid)) as f:
+ self.w(rest_publish(self, f.read()))
if node is not None:
self.subsections_links(node)
self.w(u'<div class="hr"></div>')
@@ -200,7 +201,8 @@
break
else:
raise NotFound
- self.w(open(join(resourcedir, rid)).read())
+ with io.open(join(resourcedir, rid)) as f:
+ self.w(f.read())
class HelpAction(action.Action):