sphinx-gallery: TypeError when creating links from gallery to documentation
I’m using the excellent sphinx-gallery extension in my python project py-pde. The documentation is hosted on readthedocs and things worked perfectly until very recently. Since a few days every documentation build fails with the following traceback:
[...]
copying static files... done
copying readthedocs static files... done
copying searchtools... done
copying extra files... done
dumping search index in English (code: en) ... done
dumping object inventory... done
build succeeded, 3 warnings.
The HTML pages are in _build/html.
Sphinx-gallery successfully executed 0 out of 0 files subselected by:
gallery_conf["filename_pattern"] = '/'
gallery_conf["ignore_pattern"] = '.*movie.*'
after excluding 16 files that had previously been run (based on MD5).
embedding documentation hyperlinks...
embedding documentation hyperlinks for examples_gallery... [ 5%] simple.html
Traceback (most recent call last):
File "/home/docs/checkouts/readthedocs.org/user_builds/py-pde/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/py-pde/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 369, in build
self.emit('build-finished', None)
File "/home/docs/checkouts/readthedocs.org/user_builds/py-pde/envs/latest/lib/python3.7/site-packages/sphinx/application.py", line 510, in emit
return self.events.emit(event, self, *args)
File "/home/docs/checkouts/readthedocs.org/user_builds/py-pde/envs/latest/lib/python3.7/site-packages/sphinx/events.py", line 80, in emit
results.append(callback(*args))
File "/home/docs/checkouts/readthedocs.org/user_builds/py-pde/envs/latest/lib/python3.7/site-packages/sphinx_gallery/docs_resolv.py", line 442, in embed_code_links
_embed_code_links(app, gallery_conf, gallery_dir)
File "/home/docs/checkouts/readthedocs.org/user_builds/py-pde/envs/latest/lib/python3.7/site-packages/sphinx_gallery/docs_resolv.py", line 340, in _embed_code_links
for modname in (cobj['module_short'], cobj['module']):
TypeError: string indices must be integers
Exception occurred:
File "/home/docs/checkouts/readthedocs.org/user_builds/py-pde/envs/latest/lib/python3.7/site-packages/sphinx_gallery/docs_resolv.py", line 340, in _embed_code_links
for modname in (cobj['module_short'], cobj['module']):
TypeError: string indices must be integers
The full traceback has been saved in /tmp/sphinx-err-osihz662.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!
The documentation builds without any problem on my own computer, where I sue Sphinx v2.4.4. Readthedocs reports that it uses Sphinx v1.8.5, which is certainly not the newest but should be sufficient per the sphinx-gallery documentation. Is there anything I can do on my side? Do you require more information?
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 27 (16 by maintainers)
example_code_objshould be a dict of list of dict. For some reason yours is a dict of dict (not embedded within a list). I’m not sure how this could happen from the code:example_code_objin the code comes fromidentify_names:https://github.com/sphinx-gallery/sphinx-gallery/blob/master/sphinx_gallery/gen_rst.py#L809-L813
identify_namesonly creates dict of list of dict:https://github.com/sphinx-gallery/sphinx-gallery/blob/master/sphinx_gallery/backreferences.py#L195-L231
This file simply gets loaded and parsed assuming it’s a dict of list of dict:
https://github.com/sphinx-gallery/sphinx-gallery/blob/master/sphinx_gallery/docs_resolv.py#L324-L340
Can you try on the branch from #637, which explicitly checks the types in a couple of places?
I attached it to the email, but it didn’t go through 😃 Here is a zipped version, since GitHub does not like the pickle extension:
spherical_grid_codeobj.pickle.zip