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

The following example code snippet makes sphinx-gallery crash #149

NelleV opened this Issue Oct 1, 2016 · 2 comments


None yet
2 participants

NelleV commented Oct 1, 2016

matplotlib has a fairly long and complicated example that makes sphinx-gallery crash. Here is the smallest example I extracted from i:



from __future__ import print_function

import code

class Class(code.InteractiveConsole):

    def method(self, source):
        code = self.compile(source)

    def compile(self, source):
        return source

The traceback is:

Exception occurred:
  File "/home/nelle/.miniconda3/lib/python3.5/site-packages/sphinx_gallery/", line 106, in identify_names
    module, attribute = full_name.rsplit('.', 1)
ValueError: not enough values to unpack (expected 2, got 1)
The full traceback has been saved in /tmp/sphinx-err-fosv6f05.log, if you want to report the issue to the developers.

The full example that makes sphinx-gallery crash is here:


This comment has been minimized.


lesteve commented Oct 3, 2016

I can reproduce. A work-around is to use another name than code. It seems like that the reference resolver is confused between the code module and the code local variable for some reason I haven't really understood yet.


This comment has been minimized.


lesteve commented Nov 23, 2016

Full disclosure: #173 fixes the obvious error but I am not sure what will happen with the reference solver when the same name refers to two different objects. I don't believe the reference solver knows about scope and I don't think this is a priority to make it aware of scope.

@Titan-C Titan-C closed this in #173 Nov 27, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment