Remove unecessary try/finally: in _multicall#277
Remove unecessary try/finally: in _multicall#277bluetech wants to merge 2 commits intopytest-dev:mainfrom
Conversation
In Python 3, every raisable thing inherits from BaseException, so the `except BaseException` in the code already handles every possible exit. So we can reduce the indentation and the slight overhead of `try`. Diff better viewed with `git diff -w`.
|
Hmm, though I like this cleanup I wonder if we should wait until #260 and #244 are discussed more. I'm wondering if we should be handling Also I guess we might run into trouble if Seems like a good idea on the surface for sure. |
|
Was just thinking about this change again for some odd reason and was thinking maybe we shouldn't be catching and packing The set of exceptions that derive from it is special: Is there any reason to be catching anything but I'm pretty sure catching a |
pytest at least seems to rely on it. It has a couple of special control-flow BaseExceptions ( I haven't analyzed exactly where pytest relies on it, so it might be possible to adjust it not to rely on it. |
I feel like this might be somewhat ideal. As far as I grok deriving from As an example see |
|
Yeah the main thing that seems odd to me is catching any of these base exception types will likely have no value in result unboxing since they are all system level signals - the |
| results.append(res) | ||
| if firstresult: # halt further impl calls | ||
| break | ||
| except BaseException: |
There was a problem hiding this comment.
I think I've already stated this, but just to re-iterate: IMO instead this PR should change this to Exception and we shouldn't be handling BaseException at all (unless we need it for GeneratorExit - in which case we likely need a separate block anyway).
|
i'm deferring a merge of this until i understand the implications for async better, as a side-effect i might be ripping apart the loop anyway |
Replaces #277. The extra try has no effect.
In Python 3, every raisable thing inherits from BaseException, so the
except BaseExceptionin the code already handles every possible exit. So we can reduce the indentation and the slight overhead oftry.Diff better viewed with
git diff -w(or add?w=1in github).