Merge lp:~cjwatson/lazr.restful/docutils-0.8-compat into lp:lazr.restful

Proposed by Colin Watson on 2018-02-21
Status: Merged
Merged at revision: 217
Proposed branch: lp:~cjwatson/lazr.restful/docutils-0.8-compat
Merge into: lp:lazr.restful
Diff against target: 43 lines (+9/-2)
3 files modified
setup.py (+1/-1)
src/lazr/restful/NEWS.txt (+6/-0)
src/lazr/restful/tales.py (+2/-1)
To merge this branch: bzr merge lp:~cjwatson/lazr.restful/docutils-0.8-compat
Reviewer Review Type Date Requested Status
Maximiliano Bertacchini (community) Approve on 2018-02-21
LAZR Developers 2018-02-21 Pending
Review via email: mp+338432@code.launchpad.net

Commit message

Fix compatibility with docutils >= 0.8 under "zope.testrunner --subunit".

Description of the change

When zope.testrunner is asked for subunit output, it replaces sys.stdout with a StringIO. Following http://repo.or.cz/docutils.git/commitdiff/14cde9fb, this confuses docutils into autoclosing the stdout stream in use by subunit, which broke the Launchpad test suite following an upgrade to docutils 0.14.

_PydocParser uses epydoc.markup.restructuredtext._DocumentPseudoWriter, which never writes any output, so the simplest fix for this is just to tell docutils.core.Publisher to use docutils.io.NullOutput for its output, which removes any risk of it going anywhere near stdout.

To post a comment you must log in.
Maximiliano Bertacchini (maxiberta) wrote :

Looks good to me.

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'setup.py'
2--- setup.py 2016-02-17 01:07:21 +0000
3+++ setup.py 2018-02-21 15:07:55 +0000
4@@ -53,7 +53,7 @@
5 'src/lazr/restful/NEWS.txt'),
6 license='LGPL v3',
7 install_requires=[
8- 'docutils',
9+ 'docutils>=0.3.7',
10 'epydoc', # used by wadl generation
11 'grokcore.component==1.6',
12 'lazr.batchnavigator>=1.2.0-dev',
13
14=== modified file 'src/lazr/restful/NEWS.txt'
15--- src/lazr/restful/NEWS.txt 2017-06-29 00:36:47 +0000
16+++ src/lazr/restful/NEWS.txt 2018-02-21 15:07:55 +0000
17@@ -2,6 +2,12 @@
18 NEWS for lazr.restful
19 =====================
20
21+0.20.1
22+======
23+
24+Adjust docstring rendering to avoid closing sys.stdout when running under
25+"zope.testrunner --subunit" with docutils >= 0.8.
26+
27 0.20.0 (2017-06-29)
28 ===================
29
30
31=== modified file 'src/lazr/restful/tales.py'
32--- src/lazr/restful/tales.py 2016-02-17 01:07:21 +0000
33+++ src/lazr/restful/tales.py 2018-02-21 15:07:55 +0000
34@@ -83,7 +83,8 @@
35 self.writer = _DocumentPseudoWriter()
36 self.publisher = Publisher(_EpydocReader(self.errors),
37 writer=self.writer,
38- source_class=io.StringInput)
39+ source_class=io.StringInput,
40+ destination_class=io.NullOutput)
41 self.publisher.set_components('standalone', 'restructuredtext',
42 'pseudoxml')
43 settings_overrides={

Subscribers

People subscribed via source and target branches