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

DM-12656: Replace bare except with except Exception #46

Merged
merged 1 commit into from
Nov 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions python/lsst/sconsUtils/builders.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ def ProductDir(env, product):
global _productDirs
try:
_productDirs
except:
except Exception:
Copy link
Contributor

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.

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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?

try:
_productDirs = eupsForScons.productDir(eupsenv=eupsForScons.getEups())
except TypeError: # old version of eups (pre r18588)
Expand Down Expand Up @@ -377,7 +377,7 @@ def _quote_paths(pathList):
for output, path in zip(self.outputs, self.outputPaths):
try:
allOutputs.remove(output.lower())
except:
except Exception:
state.log.fail("Unknown Doxygen output format '%s'." % output)
state.log.finish()
outConfigFile.write("GENERATE_%s = YES\n" % output.upper())
Expand Down
2 changes: 1 addition & 1 deletion python/lsst/sconsUtils/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ def runExternal(cmd, fatal=False, msg=None):
if msg is None:
try:
msg = "Error running %s" % cmd.split()[0]
except:
except Exception:
msg = "Error running external command"
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
stdout, stderr = process.communicate()
Expand Down