You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Sure @JanukanS, thanks. We don't usually assign issues. So you can search for these type of calls and simply open a PR with suggested changes linking this issue.
@ayao451 please feel free. A good place to start might be by checking the PRs linked in this issue: exception chaining has been added in quite a few places, and a few other instances have been identified as better off unchanged (e.g. nested exceptions in the test suite).
A lot of these instances have been fixed (thanks to all the contributors for this!) It would be nice to have a "definition of done" for this issue if anyone wants to do a little forensics to see what's already been tackled, what's been reviewed and determined better left as-is, and what still remains to be done.
@rossbar I think I can help the 'forensics' you describe above. My thought was to create a regex expression to search for instances of nested exceptions in the codebase (excluding tests). Something like (\s*)except .*\n(\1\s+.*\n)*\1\s+raise to capture the indentation level of the original except statement, then searching for raise within that indent block.
Then I could cross-reference that list with those instances that have already been addressed in the PRs above, and make a table of what's been addressed and what still needs to be reviewed.
Does that seem like a reasonable approach? I'm a complete beginner, found this issue through the 'good first issue' tag, so just want to ensure I'm not going down a rabbit hole or creating additional confusion.
@nkleinbaer that approach sounds reasonable, and I think tabulating the results in this issue would be very useful. Even if the cross-referencing proves to be difficult to automate, having a list of all of the potential instances for exception chaining would help finish off this issue. If you are interested in taking this on I think that'd be great! Feel free ping with any questions/comments.
OK, to start off here is a table of the files that have been touched in reference to this issue, the number of instances reviewed, the action taken, and associated PRs. I've used the nomenclature "Implemented exception chaining" to indicate something of the form except SomeError as e: raise SomeOtherError from e and "Explicitly silenced exception chaining" to indicate the form except SomeError as e: raise SomeOtherError from None. Please correct if the this can be phrased better.
In some cases my regex found additional instances of 'nested' exceptions in these files that I do not see included in the PRs. It may be the case that they were intentionally left as is, but because I cannot find any documented 'review' of them I have included them for completeness.
A bit confused on what happened here. My regex finds 8 instances total - I think all have been reviewed and some were determined to be better left as is in #16218, may be worth a second look
And here is a table of additional files/instances found by my regex that have NOT yet been reviewed in a PR related to this issue. Some of these look like they are already handling exception chaining properly (example einsumfunc.py), but again included here for completeness because I see no documentation of an explicit review.
Thanks for taking the time to put this report together @nkleinbaer , this is a really nice review of the current state of things!
I think the most effective way to present the information to help close this issue would be if we could take all of the instances that you found in your regex search, and list them using a list of checkboxes, e.g.
where instances that have been changed or reviewed get a check, and instances that haven't been addressed yet are left un-checked. That way, we have a running list of the instances where a decision has been made (whether to chain exceptions, use from None, or leave as-is) so that contributors can focus on the remaining ones.
which I believe GitHub will summarize in a progress bar for the issue.
If it is easy for you to re-organize your results in this way and you don't mind the extra effort, it'd be great if you could add a list formatted as described in a comment below, then I will take the list and move it up to the top comment so it is more visible. You've already done plenty though, so if you don't have the bandwidth that's totally fine - just let me know and I'll organize the list using your results. Thanks for all you've done so far!
Sure, I can do that! I actually wanted to have check boxes in the tables above, but couldn't figure out how to do the formatting (not sure if possible at all). Mega-checklist to follow.
Hello everyone. I'm new to open-source and I want to start doing some work.
Can I jump in and contribute to the solution of this issue? As you see I already tried to commit some code but it failed on few tests. Can somebody explain what went wrong? @eric-wieser perhaps?
... with that please realize that this is a low priority issue, so PRs may take a while to get reviewed and merged. And as I commented above:
We would like to suggest that contributors show the output from the error. This will require you think about the error: is the code path actually hit? Does it make sense to chain the exception?
I think I agree @mattip, feel free to close. We can still review any remaining open PRs.
I'm curious if any contributors who contributed for the first time to numpy thanks to this issue ended up making further contributions later, or if they've all just been drive-by one-off contributions.
Activity
seberg commentedon Apr 17, 2020
Sure @JanukanS, thanks. We don't usually assign issues. So you can search for these type of calls and simply open a PR with suggested changes linking this issue.
keremh commentedon Apr 18, 2020
Hi @seberg
I determined the part to be changed, can i work on this issue too?
MAINT: Chain exceptions and use NameError in np.bmat (#16215)
ayao451 commentedon Jun 30, 2020
Can I work on this issue? It is my first issue and I want to give it a try!
MAINT: Chain exceptions in npyio.py (gh16121)
rossbar commentedon Jul 1, 2020
@ayao451 please feel free. A good place to start might be by checking the PRs linked in this issue: exception chaining has been added in quite a few places, and a few other instances have been identified as better off unchanged (e.g. nested exceptions in the test suite).
rossbar commentedon Jul 12, 2020
A lot of these instances have been fixed (thanks to all the contributors for this!) It would be nice to have a "definition of done" for this issue if anyone wants to do a little forensics to see what's already been tackled, what's been reviewed and determined better left as-is, and what still remains to be done.
nkleinbaer commentedon Jul 17, 2020
@rossbar I think I can help the 'forensics' you describe above. My thought was to create a regex expression to search for instances of nested exceptions in the codebase (excluding tests). Something like
(\s*)except .*\n(\1\s+.*\n)*\1\s+raiseto capture the indentation level of the originalexceptstatement, then searching forraisewithin that indent block.Then I could cross-reference that list with those instances that have already been addressed in the PRs above, and make a table of what's been addressed and what still needs to be reviewed.
Does that seem like a reasonable approach? I'm a complete beginner, found this issue through the 'good first issue' tag, so just want to ensure I'm not going down a rabbit hole or creating additional confusion.
rossbar commentedon Jul 18, 2020
@nkleinbaer that approach sounds reasonable, and I think tabulating the results in this issue would be very useful. Even if the cross-referencing proves to be difficult to automate, having a list of all of the potential instances for exception chaining would help finish off this issue. If you are interested in taking this on I think that'd be great! Feel free ping with any questions/comments.
nkleinbaer commentedon Jul 18, 2020
OK, to start off here is a table of the files that have been touched in reference to this issue, the number of instances reviewed, the action taken, and associated PRs. I've used the nomenclature "Implemented exception chaining" to indicate something of the form
except SomeError as e: raise SomeOtherError from eand "Explicitly silenced exception chaining" to indicate the formexcept SomeError as e: raise SomeOtherError from None. Please correct if the this can be phrased better.In some cases my regex found additional instances of 'nested' exceptions in these files that I do not see included in the PRs. It may be the case that they were intentionally left as is, but because I cannot find any documented 'review' of them I have included them for completeness.
numpy/numpy/ctypeslib.py
Line 151 in 6ef5ec3
numpy/numpy/core/records.py
Line 495 in 6ef5ec3
numpy/numpy/lib/index_tricks.py
Line 378 in 6ef5ec3
numpy/numpy/lib/shape_base.py
Line 774 in 6ef5ec3
numpy/numpy/lib/shape_base.py
Line 868 in 6ef5ec3
numpy/numpy/ma/core.py
Line 446 in 6ef5ec3
numpy/numpy/ma/core.py
Line 463 in 6ef5ec3
numpy/numpy/ma/core.py
Line 3794 in 6ef5ec3
nkleinbaer commentedon Jul 18, 2020
And here is a table of additional files/instances found by my regex that have NOT yet been reviewed in a PR related to this issue. Some of these look like they are already handling exception chaining properly (example einsumfunc.py), but again included here for completeness because I see no documentation of an explicit review.
numpy/numpy/__init__.py
Line 127 in 6ef5ec3
numpy/numpy/__init__.py
Line 292 in 6ef5ec3
numpy/numpy/compat/py3k.py
Line 173 in 6ef5ec3
numpy/numpy/core/_type_aliases.py
Line 47 in 6ef5ec3
numpy/numpy/core/einsumfunc.py
Line 583 in 6ef5ec3
numpy/numpy/core/einsumfunc.py
Line 598 in 6ef5ec3
numpy/numpy/core/code_generators/genapi.py
Line 283 in 6ef5ec3
numpy/numpy/distutils/conv_template.py
Line 219 in 6ef5ec3
numpy/numpy/distutils/conv_template.py
Line 239 in 6ef5ec3
numpy/numpy/distutils/conv_template.py
Line 287 in 6ef5ec3
numpy/numpy/distutils/conv_template.py
Line 324 in 6ef5ec3
numpy/numpy/distutils/mingw32ccompiler.py
Line 563 in 6ef5ec3
numpy/numpy/distutils/unixccompiler.py
Line 52 in 6ef5ec3
numpy/numpy/distutils/unixccompiler.py
Line 124 in 6ef5ec3
numpy/numpy/distutils/command/config.py
Line 53 in 6ef5ec3
numpy/numpy/distutils/command/config.py
Line 96 in 6ef5ec3
numpy/numpy/distutils/command/config.py
Line 456 in 6ef5ec3
numpy/numpy/distutils/fcompiler/__init__.py
Line 613 in 6ef5ec3
numpy/numpy/distutils/fcompiler/__init__.py
Line 681 in 6ef5ec3
numpy/numpy/distutils/fcompiler/compaq.py
Line 82 in 6ef5ec3
numpy/numpy/distutils/fcompiler/compaq.py
Line 87 in 6ef5ec3
numpy/numpy/distutils/fcompiler/compaq.py
Line 91 in 6ef5ec3
numpy/numpy/distutils/fcompiler/environment.py
Line 35 in 6ef5ec3
numpy/numpy/fft/_pocketfft.py
Line 113 in 6ef5ec3
numpy/numpy/lib/arraypad.py
Line 785 in 6ef5ec3
numpy/numpy/lib/arraysetops.py
Line 279 in 6ef5ec3
numpy/numpy/lib/arraysetops.py
Line 303 in 6ef5ec3
numpy/numpy/lib/format.py
Line 379 in 6ef5ec3
numpy/numpy/lib/format.py
Line 596 in 6ef5ec3
numpy/numpy/lib/format.py
Line 617 in 6ef5ec3
numpy/numpy/lib/format.py
Line 745 in 6ef5ec3
numpy/numpy/linalg/lapack_lite/make_lite.py
Line 264 in 6ef5ec3
numpy/numpy/ma/mrecords.py
Line 201 in 6ef5ec3
numpy/numpy/ma/mrecords.py
Line 254 in 6ef5ec3
numpy/numpy/ma/mrecords.py
Line 276 in 6ef5ec3
numpy/numpy/ma/timer_comparison.py
Line 103 in 6ef5ec3
numpy/numpy/polynomial/_polybase.py
Line 550 in 6ef5ec3
numpy/numpy/polynomial/_polybase.py
Line 608 in 6ef5ec3
rossbar commentedon Jul 19, 2020
Thanks for taking the time to put this report together @nkleinbaer , this is a really nice review of the current state of things!
I think the most effective way to present the information to help close this issue would be if we could take all of the instances that you found in your regex search, and list them using a list of checkboxes, e.g.
where instances that have been changed or reviewed get a check, and instances that haven't been addressed yet are left un-checked. That way, we have a running list of the instances where a decision has been made (whether to chain exceptions, use
from None, or leave as-is) so that contributors can focus on the remaining ones.This should give us a list like:
numpy/numpy/ctypeslib.py
Line 151 in 6ef5ec3
numpy/numpy/__init__.py
Line 127 in 6ef5ec3
which I believe GitHub will summarize in a progress bar for the issue.
If it is easy for you to re-organize your results in this way and you don't mind the extra effort, it'd be great if you could add a list formatted as described in a comment below, then I will take the list and move it up to the top comment so it is more visible. You've already done plenty though, so if you don't have the bandwidth that's totally fine - just let me know and I'll organize the list using your results. Thanks for all you've done so far!
nkleinbaer commentedon Jul 20, 2020
Sure, I can do that! I actually wanted to have check boxes in the tables above, but couldn't figure out how to do the formatting (not sure if possible at all). Mega-checklist to follow.
17 remaining items
MAINT: Chain exceptions in ctypeslib.py
labbunny commentedon Apr 21, 2021
Hello everyone. I'm new to open-source and I want to start doing some work.
Can I jump in and contribute to the solution of this issue? As you see I already tried to commit some code but it failed on few tests. Can somebody explain what went wrong? @eric-wieser perhaps?
mattip commentedon Jun 9, 2021
... with that please realize that this is a low priority issue, so PRs may take a while to get reviewed and merged. And as I commented above:
adithya-1 commentedon Aug 17, 2021
Hey @eric-wieser, I am new to open source and would like to contribute to this project. Can I work on this issue?
Fixed issue numpy#15986 in runtests.py line 250 in db1a343
Fixed issue numpy#15986 in benchmarks/benchmarls/bench_ufunc.py in li…
refactor exceptions handling due to issue numpy#15986
refactor exceptions handling due to issue numpy#15986
Import directory debugged and readdressed
mattip commentedon Aug 19, 2021
I think we have gotten about as much mileage as possible from this issue and would like to close it. @eric-wieser what do you think?
eric-wieser commentedon Aug 19, 2021
I think I agree @mattip, feel free to close. We can still review any remaining open PRs.
I'm curious if any contributors who contributed for the first time to numpy thanks to this issue ended up making further contributions later, or if they've all just been drive-by one-off contributions.
mattip commentedon Aug 19, 2021
Maybe they are now contributing elsewhere.