-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Sphinxext: display shorter error traceback when :okexcept: is specified #8686
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
Sphinxext: display shorter error traceback when :okexcept: is specified #8686
Conversation
Not entirely sure about this - wouldn't you want the output to match what a user would see if they actually run that? On the other hand, since we don't use the IPython Sphinx directive ourselves, I'm happy for those who do to take the lead. |
I understand, and that's why I certainly can make it optional if needed. For our docs, I think that the full traceback only adds clutter to the documentation, that can overshadow what you actually want to show (error tracebacks can get much longer than the one in the example I gave). Furthermore, the full traceback is most of the time not that interesting (apart from where it was initially raised, but for the docs this is something like |
That makes sense. I think I'd lean towards making an option for it, but it's probably best to ask the users: would anyone enable 'show the full traceback' if it was an option? |
I would like a truncated traceback that shows the inner most frame or two. Gives a bit more context to match what the users see when something blows up. |
@tacaswell What do you mean exactly with the inner most? Using the example from the docs I linked, I would expect that you mean:
while I would think that for a user the outer most frame (where it is raised in the user his code) is the most useful to see:
But of course, for the docs it is maybe not really about what is useful for the user in real world, but that it matches somewhat the actual output. To meet the different needs, I could eg make a config option |
My thought was that if the user is sitting in the repl and then get a deep trackback they will only be able to see the inner frame or two so showing them that will help with scanning/pattern matching. |
# if :okexcept: has been specified, display shorter traceback | ||
if is_okexcept and "Traceback" in processed_output: | ||
traceback = processed_output.split('\n') | ||
processed_output= '\n'.join(traceback[-2:]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
processed_output
is all the output corresponding to that chunk of code, right? So if anything is printed before the traceback, this discards it?
What the status of this ? |
The status is that I have to look at this again, but do not have the time right now (trying to finish a phd and such things ...). |
So you can close it with a closed-pr label for now, unless someone wants to take this up in the short term |
No problem. Get your PhD. I'll see if we can find someone to revive this ! |
Tagging as Also, we are doing our best to enable people to learn how to contribute to the project, and get commits in. If you are missing time or have any other issues that prevent you to work on that, please feel free to tell us, we can try to build on top of what you did. Thanks a lot and looking forward to see this moving forward again. @jorisvandenbossche : See you after your PhD ! Hope things are moving forward ! |
This is a small patch to push a pandas change upstream (pandas-dev/pandas#10727).
When using
:okexcept:
for code blocks that are not suppressed (e.g. you want to show that a certain line of code raises an error), at this moment the full error traceback is shown. While for documentation/education purposes, it is enough/better to only show the error message itself.E.g instead of the full traceback you see in the docs here: http://pandas.pydata.org/pandas-docs/version/0.16.2/timeseries.html#ambiguous-times-when-localizing, you would get:
Open questions:
------...
) of the traceback as well.cc @chebee7i @tacaswell (as other users of / contributors to the ipython directive)