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
DM-12656: Replace bare except with except Exception #46
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good, with one question about existing code
@@ -237,7 +237,7 @@ def ProductDir(env, product): | |||
global _productDirs | |||
try: | |||
_productDirs | |||
except: | |||
except Exception: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This change is fine but I'm puzzled what the try
is for. When the module is first loaded _productDirs is sure to be undefined so the try
is sure to run, attempting to compute _productDirs
. Naively I would expect the outer try/except block to do nothing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First time through it's not set.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
First time through the try/except fires. How is that different than getting rid of the outer try/except and just setting _productDirs
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic is 6 years old. We could work around it by setting the variable to none at module scope and then checking for is None
rather than doing the try
block. I'm inclined to leave it alone for the moment.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, I guess. I am just trying to understand if the try/except is actually doing anything at all. Have you tried removing it to see if it still works?
That pattern is generally used if someone might have set _productDirs before importing for the first time, so setting to None is inappropriate. But that's usually for debug/display sorts of things
R
|
No description provided.