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

exceptions in ipython sphinx directive not reported #10402

Open
ibell opened this issue Mar 19, 2017 · 3 comments
Open

exceptions in ipython sphinx directive not reported #10402

ibell opened this issue Mar 19, 2017 · 3 comments

Comments

@ibell
Copy link
Contributor

ibell commented Mar 19, 2017

Exceptions in an ipython sphinx directive, something like

.. ipython::

    In [0]: throw ValueError()

are not output to the shell when the sphinx build happens, but now are silently ignored, though the traceback is written out to the output in HTML/PDF...:

In [1]: throw ValueError()
  File "<ipython-input-1-af7bbb4db1fc>", line 1
    throw ValueError()
                   ^
SyntaxError: invalid syntax

If an exception occurs in an imported module, the full traceback is shown in the sphinx build log. It would be better if there was at least a warning in the sphinx build to let you know that there was a problem in the build, otherwise you have to look at each output page to find errors

@ibell
Copy link
Contributor Author

ibell commented Mar 19, 2017

Nothing is printed to stdout because there is no "Traceback" in the output, as you can see from this block in the code (https://github.com/ipython/ipython/blob/master/IPython/sphinxext/ipython_directive.py#L506-L512) :

if not is_okexcept and "Traceback" in processed_output:
            s =  "\nException in %s at block ending on line %s\n" % (filename, lineno)
            s += "Specify :okexcept: as an option in the ipython:: block to suppress this message\n"
            sys.stdout.write('\n\n>>>' + ('-' * 73))
            sys.stdout.write(s)
            sys.stdout.write(processed_output)
            sys.stdout.write('<<<' + ('-' * 73) + '\n\n')

@ibell
Copy link
Contributor Author

ibell commented Mar 19, 2017

Not sure how best to handle this elegantly....

@jorisvandenbossche
Copy link
Contributor

jorisvandenbossche commented Mar 20, 2017

Is SyntaxError the only error that does not have a Traceback?
In that case you could easily change the Traceback check to

and ("Traceback" in processed_output or "SyntaxError" in processed_output):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants