Add new exception-reporting mode and %tb mode option.#11509
Merged
Conversation
This shows only the exception with no Traceback. If the Traceback is needed, it can be retrieved using %tb.
This makes it easy to access a more verbose representation that the
currently-active exception reporting mode provides.
```python
In [1]: %xmode minimal
Exception reporting mode: Minimal
In [2]: def f():
...: 3/0
...:
In [3]: f()
ZeroDivisionError: division by zero
In [4]: %tb verbose
---------------------------------------------------------------------------
ZeroDivisionError Traceback (most recent call last)
<ipython-input-3-c43e34e6d405> in <module>
----> 1 f()
global f = <function f at 0x10e52de18>
<ipython-input-2-cd4172d70b5b> in f()
1 def f():
----> 2 3/0
3
ZeroDivisionError: division by zero
In [5]: f() # The default reporting mode has not been changed....
ZeroDivisionError: division by zero
```
6b38657 to
188d043
Compare
Member
|
I'm +1 in principle. Will review when I have time. I'll also love to have an "exception" mimebundle that could be handled by the frontend with collapsible section and stuff. |
Contributor
Author
|
I like that minebundle idea a lot. I am a little bothered by how much this omits (though it might be good to have as an option). Something interactive that shows the first couple and last couple with an expandable middle would be ideal. |
Carreau
approved these changes
Nov 29, 2018
Member
|
+1. I'm going to try to get a release soon. |
Contributor
Author
|
Thanks! |
Member
|
(and 7.2 is out, currently writing announcements) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This adds a new mode to
%xmodetentatively named'Minimal'that shows only the exception --- no traceback.In many contexts, you might say this leaves out too much information. Here is the context that I feel this will be useful in. Novice Python users are using IPython to execute rote procedures in a framework that happens to produce very deep tracebacks. They are completely lost in / overwhelmed by the full tracebacks and --- during the short time they grabble with IPython --- unable to absorb the rule, "Just scroll to the bottom." Therefore, an aggressively succinct
%xmodesetting may be less disorienting. Multiple experienced IPython users at my facility have suggested that this setting would be help elicit more useful bug reports.Of course, if the problem is not immediately clear, it will be essential to access the full traceback. This could be done by switching to a more verbose
%xmodeand then using%tbto show the most recent traceback. In order to streamline that, this PR also adds an optional parameter to%tbthat temporarily switches the exception-reporting mode for that single use.