8000 Fix exception cause in video.py by cool-RR · Pull Request #99 · google-deepmind/acme · GitHub
[go: up one dir, main page]

Skip to content

Fix exception cause in video.py #99

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
Oct 8, 2021

Conversation

cool-RR
Copy link
Contributor
@cool-RR cool-RR commented Feb 20, 2021

I recently went over Matplotlib, Pandas and NumPy, fixing a small mistake in the way that Python 3's exception chaining is used. I found one instance of this mistake in the Acme repo, and I fixed it in this PR

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.

@google-cla google-cla bot added the cla: yes label Feb 20, 2021
@cool-RR cool-RR marked this pull request as ready for review February 20, 2021 17:44
@cool-RR
Copy link
Contributor Author
cool-RR commented Feb 21, 2021

Looks like the failing test is just a CI problem unrelated to my change. Can we rerun or ignore it?

@copybara-service copybara-service bot merged commit 061c400 into google-deepmind:master Oct 8, 2021
alex-gran23 pushed a commit to Next-Step-Fusion/acme that referenced this pull request Feb 23, 2024
PiperOrigin-RevId: 401752538
Change-Id: I7c9c5540f888e44bc1906726e19733aeed12e845
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0