Issue #635 resolved

No attribute 'next'

created an issue


if I try to autodoc a module via

{{{ .. automodule:: :members: }}}

I get an jinja2.exceptions.UndefinedError: b"'sphinx.jinja2glue.idgen object' has no attribute 'next'"

If I move one directory above (so that it is in python's path) and autodoc just bar, everything works fine.

Below is the full stacktrace. I just got the code from Mercurial and my was created with sphinx-quickstart.

Thanks, maranos


Sphinx version: 1.1pre

Python version: 3.1.2

Docutils version: 0.7 release

Jinja2 version: 2.5.5

Traceback (most recent call last): File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/", line 188, in main, filenames) File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/", line 204, in build self.builder.build_update() File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/builders/", line 196, in build_update 'out of date' % len(to_build)) File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/builders/", line 255, in build self.finish() File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/builders/", line 439, in finish self.write_domain_indices() File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/builders/", line 503, in write_domain_indices self.handle_page(indexname, indexcontext, 'domainindex.html') File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/builders/", line 723, in handle_page output = self.templates.render(templatename, ctx) File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/", line 127, in render return self.environment.get_template(template).render(context) File "/usr/local/lib/python3.1/dist-packages/Jinja2-2.5.5-py3.1.egg/jinja2/", line 892, in render return self.environment.handle_exception(exc_info, True) File "/usr/local/lib/python3.1/dist-packages/Jinja2-2.5.5-py3.1.egg/jinja2/", line 668, in handle_exception raise exc_value.with_traceback(tb) File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/themes/basic/domainindex.html", line 11, in <module> {% set title = indextitle %} File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/themes/default/layout.html", line 13, in <module> {% set script_files = script_files + ['_static/sidebar.js'] %} File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/themes/basic/layout.html", line 160, in <module> {%- block content %} File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/themes/basic/layout.html", line 164, in <module> {%- block document %} File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/themes/basic/layout.html", line 170, in <module> {% block body %} {% endblock %} File "/usr/local/lib/python3.1/dist-packages/Sphinx-1.1predev_20110214-py3.1.egg/sphinx/themes/basic/domainindex.html", line 43, in <module> id="toggle-{{ }}" style="display: none" alt="-" /> File "/usr/local/lib/python3.1/dist-packages/Jinja2-2.5.5-py3.1.egg/jinja2/", line 257, in call if not self.is_safe_callable(obj): File "/usr/local/lib/python3.1/dist-packages/Jinja2-2.5.5-py3.1.egg/jinja2/", line 204, in is_safe_callable return not (getattr(obj, 'unsafe_callable', False) or \ jinja2.exceptions.UndefinedError: b"'sphinx.jinja2glue.idgen object' has no attribute 'next'" }}}

Comments (4)

  1. maranos reporter

    ok, I did some research:

    clearly the jinja2glue.idgen-object from the source code has a next-method. But after building, the jinja2glue.idgen-object in the build-directory has a


    method instead.

    Thus when in themes/basic/domainindex.html on line 43 is called, Sphinx crashes.

    Greets, Maranos

  2. foogod

    I just ran into this too.. This is clearly a case of the 2to3 conversion "fixing" something that we didn't actually want "fixed" (part of the standard behavior of 2to3 is to change "next" methods to "next" due to changes in the iterator API in Py3)

    This can probably be fixed by tweaking how 2to3 is used when generating the Py3 version of Sphinx, but until somebody implements that, I have found the following workaround:

    If you add the following lines to your, it will fixup the problem part of the code during runtime:

    import sphinx.jinja2glue
    if not hasattr(sphinx.jinja2glue.idgen, "next"): = sphinx.jinja2glue.idgen.__next__
  3. Log in to comment