-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
ERR: catchall exception should be explicity and use Exception EAFP #7948
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
Comments
i think i have a branch lying around somewhere that traverses the entirety of pandas ast and lets you know where carpet bomb exceptions are |
let me see if i can find it |
though i suppose grin 'except:' is slightly less overkill :) |
fwiw i would say that even catching |
|
EAFP is an acronym that stands for "easier to ask forgiveness than permission" and describes a principle behind the pythonic way of doing some operations that may fail:
as opposed to
pandas sources use this a lot but often the exception is caught with
except:
which among other things interceptSystemExit
andKeyboardInterrupt
. Because of that it's possible that when you're trying to interrupt an operation it goes on simply choosing another code path.There are valid use cases for carpet-catching excepts like that, most obvious ones being performing some cleanup and re-raising the error afterwards and catching all errors coming from evaluation of user-supplied code. In the rest of the cases
except Exception:
should be used instead.The text was updated successfully, but these errors were encountered: