8000 Fix exception causes in debugger.py by cool-RR · Pull Request #12377 · ipython/ipython · GitHub
[go: up one dir, main page]

Skip to content

Fix exception causes in debugger.py #12377

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

Merged
merged 1 commit into from
Jun 10, 2020

Conversation

cool-RR
Copy link
Contributor
@cool-RR cool-RR commented Jun 9, 2020

I recently went over Matplotlib, Pandas and NumPy, fixing a small mistake in the way that Python 3's exception chaining is used. If you're interested, I can do it here too. I've done it on just one file right now.

The mistake is this: In some parts of the code, an exception is being caught and replaced with a more user-friendly error. In these cases the syntax raise new_error from old_error needs to be used.

Python 3's exception chaining means it shows not only the traceback of the current exception, but that of the original exception (and possibly more.) This is regardless of raise from. The usage of raise from tells Python to put a more accurate message between the tracebacks. Instead of this:

During handling of the above exception, another exception occurred:

You'll get this:

The above exception was the direct cause of the following exception:

The first is inaccurate, because it signifies a bug in the exception-handling code itself, which is a separate situation than wrapping an exception.

Let me know what you think!

@cool-RR cool-RR marked this pull request as ready for review June 9, 2020 16:16
@Carreau
Copy link
Member
Carreau commented Jun 10, 2020

Oh, yeah, I think that would be great in some locations.
There might be places where we can have a more informative message and do from None as well to have a cleaner error message.

(Test are passing but User interface is not updating, I'll merge anyway.)

@Carreau Carreau added this to the 8.0 milestone Jun 10, 2020
@Carreau Carreau merged commit 851ea15 into ipython:master Jun 10, 2020
@Carreau
Copy link
Member
Carreau commented Jun 10, 2020

(Also I'm pretty sure I saw a thread on Python-idea about that. Started by you maybe ? )

@cool-RR
Copy link
Contributor Author
cool-RR commented Jun 10, 2020

Awesome, I'll work on the rest. Yes, I do think I discussed it on python-ideas a while back :)

I personally hate from None, so I'll just work on the places where we agree that there shouldn't be a from None. I'll assign you on the PR when it's ready.

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

Successfully merging this pull request may close these issues.

2 participants
0