Skip to content
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

Fix exception causes in parallel.py #1067

Merged
merged 1 commit into from
Jun 16, 2020
Merged

Fix exception causes in parallel.py #1067

merged 1 commit into from
Jun 16, 2020

Conversation

cool-RR
Copy link
Contributor

@cool-RR cool-RR commented Jun 11, 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!

@codecov
Copy link

codecov bot commented Jun 11, 2020

Codecov Report

Merging #1067 into master will decrease coverage by 0.02%.
The diff coverage is 33.33%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1067      +/-   ##
==========================================
- Coverage   94.23%   94.20%   -0.03%     
==========================================
  Files          47       47              
  Lines        6849     6849              
==========================================
- Hits         6454     6452       -2     
- Misses        395      397       +2     
Impacted Files Coverage Δ
joblib/parallel.py 96.45% <33.33%> (+0.27%) ⬆️
joblib/test/test_parallel.py 95.59% <0.00%> (-1.43%) ⬇️
joblib/_parallel_backends.py 94.92% <0.00%> (+0.39%) ⬆️
joblib/test/test_numpy_pickle.py 93.36% <0.00%> (+0.66%) ⬆️
joblib/compressor.py 89.14% <0.00%> (+0.98%) ⬆️
joblib/_multiprocessing_helpers.py 80.00% <0.00%> (+4.00%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update dfc11fe...be72d5d. Read the comment docs.

@ogrisel
Copy link
Contributor

ogrisel commented Jun 16, 2020

This is great. Thanks very much. Don't hesitate to open other similar PRs if you see other similar issues.

@ogrisel ogrisel merged commit ac0f152 into joblib:master Jun 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants