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

TypeError: 'generator' object is not reversible #9727

Closed
ugiwgh opened this issue Oct 11, 2021 · 12 comments
Closed

TypeError: 'generator' object is not reversible #9727

ugiwgh opened this issue Oct 11, 2021 · 12 comments

Comments

@ugiwgh
Copy link

ugiwgh commented Oct 11, 2021

Describe the bug

My cmd:
/usr/local/bin/sphinx-build -b man -t man -d /root/bu/ceph/build/doc/doctrees -c /root/bu/ceph/man /root/bu/ceph/doc/man /root/bu/ceph/build/doc/man

Error Message:
Running Sphinx v1.7.6
loading pickled environment... not yet created
building [mo]: targets for 0 po files that are out of date
building [man]: all manpages
updating environment: 46 added, 0 changed, 0 removed
reading sources... [ 2%] 8/ceph
reading sources... [ 4%] 8/ceph-authtool
reading sources... [ 6%] 8/ceph-bluestore-tool

Exception occurred:
File "/usr/local/Python-3.6.15/lib/python3.6/site-packages/Sphinx-1.7.6.dev20211011-py3.6.egg/sphinx/util/nodes.py", line 57, in apply_source_workaround
for classifier in reversed(node.parent.traverse(nodes.classifier)):
TypeError: 'generator' object is not reversible
The full traceback has been saved in /tmp/sphinx-err-jpnnyy28.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!

How to Reproduce

I download the sphinx from https://github.com/sphinx-doc/sphinx.
And build it with "python3 setup.py install".

Expected behavior

No response

Your project

https://github.com/ceph/ceph

Screenshots

No response

OS

CentOS Linux release 7.9.2009 (Core)

Python version

Python 3.6.15

Sphinx version

sphinx-1.7.6.tar.gz

Sphinx extensions

No response

Extra tools

No response

Additional context

No response

@throneofshadow
Copy link

Have this error as well.

Running Sphinx v1.8.5
loading translations [en]... done
making output directory...
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 15 source files that are out of date
updating environment: 15 added, 0 changed, 0 removed
reading sources... [ 6%] hardware/hardware
reading sources... [ 13%] index

Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/cmd/build.py", line 304, in build_main
app.build(args.force_all, filenames)
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 341, in build
self.builder.build_update()
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/builders/init.py", line 347, in build_update
len(to_build))
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/builders/init.py", line 360, in build
updated_docnames = set(self.read())
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/builders/init.py", line 468, in read
self._read_serial(docnames)
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/builders/init.py", line 490, in _read_serial
self.read_doc(docname)
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/builders/init.py", line 534, in read_doc
doctree = read_doc(self.app, self.env, self.env.doc2path(docname))
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/io.py", line 318, in read_doc
pub.publish()
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/docutils/core.py", line 219, in publish
self.apply_transforms()
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/docutils/core.py", line 200, in apply_transforms
self.document.transformer.apply_transforms()
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/transforms/init.py", line 90, in apply_transforms
Transformer.apply_transforms(self)
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/docutils/transforms/init.py", line 171, in apply_transforms
transform.apply(**kwargs)
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/transforms/init.py", line 245, in apply
apply_source_workaround(n)
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/util/nodes.py", line 94, in apply_source_workaround
for classifier in reversed(node.parent.traverse(nodes.classifier)):
TypeError: 'generator' object is not reversible

Exception occurred:
File "/home/docs/checkouts/readthedocs.org/user_builds/reachmaster/envs/latest/lib/python3.7/site-packages/sphinx/util/nodes.py", line 94, in apply_source_workaround
for classifier in reversed(node.parent.traverse(nodes.classifier)):
TypeError: 'generator' object is not reversible
The full traceback has been saved in /tmp/sphinx-err-u2codvq0.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!

@andrewegel
Copy link

andrewegel commented Oct 26, 2021

I encountered this in my own way. Check your version of docutils thats being utilized here. There was a recent docutils-0.18 release that made a note of this change: https://docutils.sourceforge.io/RELEASE-NOTES.html#release-0-18-2021-10-26

nodes.Node.traverse() returns an iterator instead of a list.

Pinning docutils==0.17.1 resolved this issue for us.

@pohmelie
Copy link

This breaks readthedocs build for me. https://readthedocs.org/projects/aioftp/builds/15099286/

@astrojuanlu
Copy link
Contributor

Hi @pohmelie , Juan Luis from Read the Docs here - that's to be expected, pin your docutils version to <0.18

@throneofshadow
Copy link

Pinning docutils to <0.18 works!!! Thanks everyone!

renierts pushed a commit to PlasmaControl/PyRCN that referenced this issue Oct 27, 2021
@JohnPaton
Copy link

Shouldn't Sphinx change its own requirements to include docutils<0.18 in this case?

@pohmelie
Copy link

@JohnPaton, actually it is already in https://github.com/sphinx-doc/sphinx/blob/4.x/setup.py#L26

@cirospat
Copy link

cirospat commented Oct 27, 2021

thanks you for your replies.
Problem solved.

pin docutils<0.18
in your requirements.txt file,
and have a .readthedocs.yaml file with these contents:

version: 2
python:
   install:
   - requirements: docs/requirements.txt

as reported by @astrojuanlu
here: readthedocs/readthedocs.org#8616 (comment)

I followed this instruction and it works! Build succes

@tk0miya
Copy link
Member

tk0miya commented Oct 27, 2021

The recommended way is upgrading Sphinx to the latest one. It has already pinned the version of docutils. I think no reason to keep using the old version of Sphinx. Let's upgrade!

@tk0miya tk0miya pinned this issue Oct 27, 2021
@joshuacwnewton
Copy link

joshuacwnewton commented Oct 27, 2021

The recommended way is upgrading Sphinx to the latest one. It has already pinned the version of docutils. I think no reason to keep using the old version of Sphinx. Let's upgrade!

Just to expand on why this is happening in the first place, if you have an RTD project that was created prior to October 2020, RTD will default to sphinx<2, unless you explicitly specify a version of Sphinx to use.

And, sphinx<2 doesn't have this line:

'docutils>=0.14,<0.18',

So, you'll want to specify the version of sphinx in RTD's requirements (see pinning dependencies in RTD's docs), then let sphinx handle its own dependencies (in this case, pinning docutils).

@tk0miya
Copy link
Member

tk0miya commented Oct 27, 2021

And, sphinx<2 doesn't have this line:

Just FYI, the line was added at v4.0. So docutils-0.18 would be installed if you're using Sphinx < 4.0.

jeffra added a commit to microsoft/DeepSpeed that referenced this issue Oct 27, 2021
jeffra added a commit to microsoft/DeepSpeed that referenced this issue Oct 27, 2021
jeffra added a commit to microsoft/DeepSpeed that referenced this issue Oct 27, 2021
@andrewegel
Copy link

I should mention, that our invocations of sphinx have been warning us about this issue for a while:

$prefix/lib/python3.X/site-packages/sphinx/util/nodes.py:94: FutureWarning: 
    The iterable returned by Node.traverse()
    will become an iterator instead of a list in Docutils > 0.16.
    for classifier in reversed(node.parent.traverse(nodes.classifier)):

While docutils didn't make this switch until 0.18, it is a reminder that we should pay attention to warnings.

bbannier added a commit to zeek/spicy that referenced this issue Nov 4, 2021
…p CI].

This resolves the build problems due to sphinx-doc/sphinx#9727 we've
been seeing.
SchoolGuy added a commit to cobbler/cobbler that referenced this issue Nov 4, 2021
This is done, so we get the required version of docutils. This is
needed because we need a version greater than 0.18.

Source: sphinx-doc/sphinx#9727 (comment)
bbannier added a commit to zeek/spicy that referenced this issue Nov 4, 2021
This resolves the build problems due to sphinx-doc/sphinx#9727 we've
been seeing. RTD seems to by default run a <sphinx-2.0 which conflicts
with newer docutils.

Since we usually install sphinx from the system for building the docs
instead pin docutils in the docs requirements file which is parsed by
RTD.
SchoolGuy added a commit to cobbler/cobbler that referenced this issue Nov 4, 2021
This is done, so we get the required version of docutils. This is
needed because we need a version greater than 0.18.

Source: sphinx-doc/sphinx#9727 (comment)
bbannier added a commit to zeek/spicy that referenced this issue Nov 4, 2021
This resolves the build problems due to sphinx-doc/sphinx#9727 we've
been seeing. RTD seems to by default run a <sphinx-2.0 which conflicts
with newer docutils.

Since we usually install sphinx from the system for building the docs
instead pin docutils in the docs requirements file which is parsed by
RTD.
ptmerz added a commit to shirtsgroup/physical_validation that referenced this issue Nov 4, 2021
RTD documentation were failing since about two weeks, related to
sphinx-doc/sphinx#9727. RTD does by default
keep sphinx at version < 2 for existing projects. Older versions of
sphinx do no define their version dependency on docutils. docutils, in
turn, was recently updated breaking compatibility with sphinx.

This change cleans up the dependencies of the RTD build, updating and
pinning the versions of the dependencies. This should make the
documentation builds stable and reproducible.
ptmerz added a commit to shirtsgroup/physical_validation that referenced this issue Nov 4, 2021
RTD documentation were failing since about two weeks, related to
sphinx-doc/sphinx#9727. RTD does by default
keep sphinx at version < 2 for existing projects. Older versions of
sphinx do no define their version dependency on docutils. docutils, in
turn, was recently updated breaking compatibility with sphinx.

This change cleans up the dependencies of the RTD build, updating and
pinning the versions of the dependencies. This should make the
documentation builds stable and reproducible.
msholes-ps added a commit to msholes-ps/py-pure-client that referenced this issue Nov 5, 2021
…ersion at <0.18

to work around issue : sphinx-doc/sphinx#9727
Sphinx is incompatible with the new docutils package.
bud42 added a commit to VUIIS/dax that referenced this issue Nov 16, 2021
amlucas added a commit to cselab/Mirheo that referenced this issue Nov 17, 2021
apdavison added a commit to NeuralEnsemble/python-neo that referenced this issue Nov 19, 2021
@tk0miya tk0miya closed this as completed Dec 22, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jan 22, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

9 participants