GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||
GeezerVison is showing github.com — Display exception notes in tracebacks by EtiennePelletier · Pull Request #14039 · ipython/ipython Conversation
Contributor
PEP 678 introduced the ability to add notes to exception objects. This has been released in Python 3.11 and is currently not implemented in IPython. These changes are fully compatible with older Python versions that don't include PEP 678. Here's a sample test that shows the consistency in Python's stdlib traceback module (test 1) and the difference between Python and IPython's runtimes (test 2): import traceback print('--- test 1 ---') try: raise Exception('Testing notes') except Exception as e: e.add_note('Does this work?') e.add_note('Yes!') traceback.print_exc() print('\n--- test 2 ---') try: raise Exception('Testing notes') except Exception as e: e.add_note('Does this work?') e.add_note('No!') raise When executed with Python 3.11, both notes are displayed in both tracebacks: In IPython's VerboseTB does not yet handle exception notes: The changes I am suggesting are inspired from implementation of Lib/traceback.py (search for Although notes are meant to be strings only, I kept some inspiration from the existing exception handling to ensure that the notes are uncolored and bytes decoded, if there are any. I am definitely open to using a different color if deemed better. For context, Here's how the test 2 looks like after these changes: 🐍 🤹♂️
Sorry, something went wrong. Uh oh!
There was an error while loading. Please reload this page. All reactions
|
There was an error while loading. Please reload this page.
|
Oops, I checked for existing issues a few hours before this was opened and then created #14040 - it has tests and a changelog, but is a bit less careful about edge cases. Cherry-pick whatever you want and then I'll close my PR? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I'm guessing you both are at PyCon sprints !? Enjoy ! I'll likely get that in during May :-). |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Changes cherry-picked, good catch Zac on the Plain traceback format! |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| *.swp | ||
| .pytest_cache | ||
| .python-version | ||
| .venv*/ |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
You likely want that in your global gitignore to not have to do it for all your repos.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Let's try this. Sorry I was mostly travelling last month. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.