Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[docutils 0.13.1] assert not self.context #3212

Closed
tardyp opened this issue Dec 9, 2016 · 16 comments
Closed

[docutils 0.13.1] assert not self.context #3212

tardyp opened this issue Dec 9, 2016 · 16 comments
Assignees
Labels
Milestone

Comments

@tardyp
Copy link

tardyp commented Dec 9, 2016

Following traceback is found when building buildbot documentation after upgrade to docutils 0.13.1

Traceback (most recent call last):
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/sphinx/cmdline.py", line 296, in main
    app.build(opts.force_all, filenames)
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/sphinx/application.py", line 333, in build
    self.builder.build_update()
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 251, in build_update
    'out of date' % len(to_build))
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 322, in build
    self.write(docnames, list(updated_docnames), method)
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 360, in write
    self._write_serial(sorted(docnames), warnings)
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/sphinx/builders/__init__.py", line 368, in _write_serial
    self.write_doc(docname, doctree)
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/sphinx/builders/html.py", line 452, in write_doc
    self.docwriter.write(doctree, destination)
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/docutils/writers/__init__.py", line 80, in write
    self.translate()
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/sphinx/writers/html.py", line 48, in translate
    self.document.walkabout(visitor)
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/docutils/nodes.py", line 187, in walkabout
    visitor.dispatch_departure(self)
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/docutils/nodes.py", line 1895, in dispatch_departure
    return method(node)
  File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/docutils/writers/_html_base.py", line 671, in depart_document
    assert not self.context, 'len(context) = %s' % len(self.context)
AssertionError: len(context) = 4

You can reproduce by downloading a copy of buildbot

git clone git@github.com:buildbot/buildbot.git
cd buildbot
pip install -e ./master[docs]'
make docs
@antnieszka
Copy link

antnieszka commented Dec 9, 2016

Similar issue with travis/tox:
https://travis-ci.org/ant6/beprof/jobs/182614760

ant6% ➜ tox -e docs                    
GLOB sdist-make: /home/ant6/PycharmProjects/beprof/setup.py
docs installed: alabaster==0.7.9,apparmor==2.10.1,Babel==2.3.4,-e git+https://github.com/DataMedSci/beprof.git@55cc6fad7d1af630b4d3f5d77782335a86e79552#egg=beprof,bottle==0.12.8,Brlapi==0.6.3,certifi==2015.9.6.2,cffi==1.1.2,coverage==3.7.1,cupshelpers==1.0,cycler==0.10.0,docutils==0.13.1,ecdsa==0.13,imagesize==0.7.1,ipython==3.2.2,Jinja2==2.8,jsonschema==2.5.1,LibAppArmor==2.10.1,louis==2.5.4,MarkupSafe==0.23,matplotlib==1.5.3.post0,mistune==0.7,nose==1.3.7,numpy==1.11.2,paramiko==1.15.2,pexpect==4.1.0,ptyprocess==0.5.1,py==1.4.30,pycparser==2.14,pycrypto==2.6.1,pycups==1.9.72,pycurl==7.19.5.1,Pygments==2.0.2,pygobject==3.16.2,pymongo==3.0.3,pyparsing==2.0.3,pysmbc==1.0.15.4,python-dateutil==2.4.2,pytz==2015.6,pyzmq==14.7.0,requests==2.7.0,scipy==0.18.1,simplejson==3.8.0,six==1.9.0,snowballstemmer==1.2.1,Sphinx==1.5,tornado==4.2.1,versioneer==0.16
docs runtests: PYTHONHASHSEED='1692403530'
docs runtests: commands[0] | pip install -e .
Obtaining file:///home/ant6/PycharmProjects/beprof
Requirement already satisfied: numpy>=1.8.0 in /usr/lib64/python3.4/site-packages (from beprof==0.post0.dev2011481296902)
Installing collected packages: beprof
  Found existing installation: beprof 0.post0.dev201
    Uninstalling beprof-0.post0.dev201:
      Successfully uninstalled beprof-0.post0.dev201
  Running setup.py develop for beprof
Successfully installed beprof
docs runtests: commands[1] | sphinx-build -b html -d /home/ant6/PycharmProjects/beprof/.tox/docs/tmp/doctrees docs docs/build/_html
Running Sphinx v1.5
loading translations [en]... done
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 4 source files that are out of date
updating environment: 4 added, 0 changed, 0 removed
reading sources... [ 25%] authors
reading sources... [ 50%] contributing
reading sources... [ 75%] index
reading sources... [100%] readme

looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [ 25%] authors
writing output... [ 50%] contributing
writing output... [ 75%] index
writing output... [100%] readme

Exception occurred:
  File "/home/ant6/PycharmProjects/beprof/.tox/docs/lib/python3.4/site-packages/docutils/writers/_html_base.py", line 671, in depart_document
    assert not self.context, 'len(context) = %s' % len(self.context)
AssertionError: len(context) = 3
The full traceback has been saved in /tmp/sphinx-err-2qj4g5b4.log, if you want to report the issue to the developers.
Please also report this if it was a user error, so that a better error message can be provided next time.
A bug report can be filed in the tracker at <https://github.com/sphinx-doc/sphinx/issues>. Thanks!
ERROR: InvocationError: '/home/ant6/PycharmProjects/beprof/.tox/docs/bin/sphinx-build -b html -d /home/ant6/PycharmProjects/beprof/.tox/docs/tmp/doctrees docs docs/build/_html'
_____________________________________________________________________________________________________________ summary ______________________________________________________________________________________________________________
ERROR:   docs: commands failed

@mtbc
Copy link

mtbc commented Dec 9, 2016

Same with https://travis-ci.org/openmicroscopy/ome-documentation/builds/182595860 -

     [exec] writing output... [ 12%] developers/Model/StructuredAnnotations
     [exec] writing output... [ 12%] developers/Model/Units
     [exec] 
     [exec] Exception occurred:
     [exec]   File "/home/travis/virtualenv/python2.7.9/lib/python2.7/site-packages/docutils/writers/_html_base.py", line 671, in depart_document
     [exec]     assert not self.context, 'len(context) = %s' % len(self.context)
     [exec] AssertionError: len(context) = 2
     [exec] The full traceback has been saved in /tmp/sphinx-err-pe_H_o.log, if you want to report the issue to the developers.
     [exec] Please also report this if it was a user error, so that a better error message can be provided next time.
     [exec] A bug report can be filed in the tracker at <https://bitbucket.org/birkenfeld/sphinx/issues/>. Thanks!
     [exec] writing output... [ 13%] developers/Model/XsltTransformations

In our .travis.yml we do pip install Sphinx==1.2.3 so could this new issue be in a dependency?

@tardyp
Copy link
Author

tardyp commented Dec 9, 2016

It looks like it comes from docutils 0.13.1

pip install docutils==0.12   # fixes the issue.

After investigation:

  • self.context contains 4 empty strings

  • those empty strings are inserted in visit_image from html.py
    File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/docutils/nodes.py", line 1882, in dispatch_visit
    return method(node)

    File "/Users/ptardy/dev/bb/buildbot/sandbox/lib/python2.7/site-packages/sphinx/writers/html.py", line 476, in visit_image
    self.context.append('')

@tardyp
Copy link
Author

tardyp commented Dec 9, 2016

@gmilde @grubert the maintainers of docutils may have some ideas

@tardyp tardyp changed the title [sphinx 1.5] assert not self.context [docutils 0.13.1] assert not self.context Dec 9, 2016
tardyp added a commit to tardyp/buildbot that referenced this issue Dec 9, 2016
@antnieszka
Copy link

docutils <0.13.1 worked for me, thanks 😄

patkan added a commit to python-escpos/python-escpos that referenced this issue Dec 9, 2016
version 0.13 of docutils seems to have problems. See
sphinx-doc/sphinx#3212
patkan added a commit to python-escpos/python-escpos that referenced this issue Dec 9, 2016
version 0.13 of docutils seems to have problems. See
sphinx-doc/sphinx#3212
@gmilde
Copy link

gmilde commented Dec 9, 2016

Sphinx overwrites visit_item() but not depart_item() in writer.html.

For other functions, it keeps the pair together:

# overwritten (but not changed) to keep pair of visit/depart_definition

This is the right thing to do:

Docutils html writer has a changed visit_item() function in version 0.13, which does not use the
heterogeneous "context" stack. Therefore, also the depart_item() was changed to just pass.

Copying the old depart_image() function to writers/html.py should solve the issue.

--- /usr/lib/python2.7/dist-packages/sphinx/writers/html.py	2016-10-01 17:14:37.000000000 +0200
+++ /tmp/html23031.4203.py	2016-12-09 22:19:36.815344886 +0100
@@ -498,6 +498,10 @@
                     node['height'] = str(size[1])
     BaseTranslator.visit_image(self, node)

+    # overwritten (but not changed) to keep pair of visit/depart_image
+    def depart_image(self, node):
+        self.body.append(self.context.pop())
+
 def visit_toctree(self, node):
     # this only happens when formatting a toc from env.tocs -- in this
     # case we don't want to include the subtree

``

grzanka added a commit to DataMedSci/pymchelper that referenced this issue Dec 10, 2016
@tk0miya tk0miya self-assigned this Dec 10, 2016
@tk0miya tk0miya added this to the 1.5.1 milestone Dec 10, 2016
tk0miya added a commit to tk0miya/sphinx that referenced this issue Dec 10, 2016
tk0miya added a commit to tk0miya/sphinx that referenced this issue Dec 10, 2016
nbassler pushed a commit to DataMedSci/pymchelper that referenced this issue Dec 10, 2016
tk0miya added a commit that referenced this issue Dec 10, 2016
Fix #3212: HTML Builders crashes with docutils-0.13
nijel added a commit to WeblateOrg/weblate that referenced this issue Dec 10, 2016
See sphinx-doc/sphinx#3212

Signed-off-by: Michal Čihař <michal@cihar.com>
@SylvainCorlay
Copy link

I am actually seeing the same error on RTD with docutils 0.12. (unless the version number displayed by RTD does not actually reflect the installed version of docutils ).

https://readthedocs.org/projects/ipywidgets/builds/4771583/

@tk0miya
Copy link
Member

tk0miya commented Dec 10, 2016

@SylvainCorlay Your case is similar to this, but not related issue.
could you file a new issue?

@tk0miya
Copy link
Member

tk0miya commented Dec 10, 2016

Merged #3217.

@tk0miya tk0miya closed this as completed Dec 10, 2016
@tk0miya
Copy link
Member

tk0miya commented Dec 10, 2016

@SylvainCorlay Hmm? It seems your case is same as this issue.

Exception occurred:
  File "/home/docs/checkouts/readthedocs.org/user_builds/ipywidgets/conda/latest/lib/python3.5/site-packages/docutils/writers/_html_base.py", line 671, in depart_document
    assert not self.context, 'len(context) = %s' % len(self.context)
AssertionError: len(context) = 9

docutils/writers/_html_base.py is new file since docutils-0.13. It's not docutils-0.12.

At my local, it was also fixed by #3217.

HeatherAtiFactor added a commit to HeatherAtiFactor/www that referenced this issue May 15, 2017
Added requirement for docutils to support Windows builds
See GitHub issue sphinx-doc/sphinx#3212
ggarnier added a commit to tsuru/tsuru that referenced this issue May 15, 2017
nharraud pushed a commit to nharraud/invenio-jsonschemas that referenced this issue Jun 2, 2017
* Update Flask version.

* Fixes isort issue in a test file.

* Fixes sphinx issue related to python 3 types refrences.
  (see https://bugs.python.org/issue11975)

* Fixes sphinx build by updating to the last version. See
  sphinx-doc/sphinx#3212

Signed-off-by: Nicolas Harraudeau <nicolas.harraudeau@cern.ch>
yeganer added a commit to yeganer/tardis that referenced this issue Jun 13, 2017
yeganer added a commit to yeganer/tardis that referenced this issue Jun 14, 2017
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Aug 3, 2017
PR:		221116
Submitted by:	pgj
Approved by:	araujo (maintainer)
Obtained from:	sphinx-doc/sphinx#3212
MFH:		2017Q3


git-svn-id: svn+ssh://svn.freebsd.org/ports/head@447275 35697150-7ecd-e111-bb59-0022644237b5
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Aug 3, 2017
PR:		221116
Submitted by:	pgj
Approved by:	araujo (maintainer)
Obtained from:	sphinx-doc/sphinx#3212
MFH:		2017Q3
openstack-gerrit pushed a commit to openstack-archive/tripleo-common that referenced this issue Aug 9, 2017
These links are breaking the docs build for tripleo-common on
stable/ocata effectively blocking us from merging any code on that
branch.

The bug was reported to sphinx and has been fixed:
sphinx-doc/sphinx#3212

However, we don't have the newer version of sphinx in stable/ocata due
to the pin in test-requirements.txt coming from the global requirements
repo.

Change-Id: I06da2e01b898a303c445331387850a8cf1e24827
Partial-Bug: #1709152
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Aug 17, 2017
Backport fix for issue #3212

PR:		221116
Submitted by:	pgj
Approved by:	araujo (maintainer)
Obtained from:	sphinx-doc/sphinx#3212

Approved by:	ports-secteam (with hat)
mtiller added a commit to mtiller/ModelicaBook that referenced this issue Nov 3, 2017
This caused the Sphinx build to fail.  For
more info, see:

# Because I was running into this: sphinx-doc/sphinx#3212
uqs pushed a commit to freebsd/freebsd-ports that referenced this issue Apr 1, 2021
Backport fix for issue #3212

PR:		221116
Submitted by:	pgj
Approved by:	araujo (maintainer)
Obtained from:	sphinx-doc/sphinx#3212

Approved by:	ports-secteam (with hat)
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 29, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

8 participants