# HG changeset patch # User Denis Laxalde # Date 1530181156 -7200 # Node ID 04ff0d3ef1d39d1c82a3dae3d4449de32371825f # Parent 90ff36da4c8eab66b6d15792ad8489bbfdfa904a [py3] Use "utf-8" as input encoding for docutils in rest extension Docutils says that "unicode" is an unknown encoding on Python3. Not sure where "unicode" as an encoding comes (it's there since showtime) but "utf-8" seems more appropriate. From now on, rendering of CubicWeb's rst directive (e.g. ..winclude) works on Python 3. Accordingly, we extend wdoc's test to demonstrate this. For this we need to install docutils in tox's web environment. diff -r 90ff36da4c8e -r 04ff0d3ef1d3 cubicweb/ext/rest.py --- a/cubicweb/ext/rest.py Thu Jun 28 11:19:14 2018 +0200 +++ b/cubicweb/ext/rest.py Thu Jun 28 12:19:16 2018 +0200 @@ -404,7 +404,7 @@ """ req = context._cw if isinstance(data, text_type): - encoding = 'unicode' + encoding = 'utf-8' # remove unprintable characters unauthorized in xml data = data.translate(ESC_UCAR_TABLE) else: diff -r 90ff36da4c8e -r 04ff0d3ef1d3 cubicweb/web/test/unittest_views_wdoc.py --- a/cubicweb/web/test/unittest_views_wdoc.py Thu Jun 28 11:19:14 2018 +0200 +++ b/cubicweb/web/test/unittest_views_wdoc.py Thu Jun 28 12:19:16 2018 +0200 @@ -7,6 +7,9 @@ with self.admin_access.web_request(fid='main') as req: page = req.view('wdoc') self.assertIn(u'Site documentation', page) + # This part is renderend through rst extension (..winclude directive). + self.assertIn(u'This web application is based on the CubicWeb knowledge management system', + page) if __name__ == '__main__': diff -r 90ff36da4c8e -r 04ff0d3ef1d3 requirements/test-web.txt --- a/requirements/test-web.txt Thu Jun 28 11:19:14 2018 +0200 +++ b/requirements/test-web.txt Thu Jun 28 12:19:16 2018 +0200 @@ -1,3 +1,4 @@ +docutils Twisted < 16.0.0 requests webtest