Skip to content

[Python] Fix blind "except:" statements #1571

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

Merged
merged 1 commit into from
Mar 8, 2016
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions benchmark/scripts/Benchmark_Driver
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def log_results(log_directory, driver, formatted_output, swift_repo=None):
"""
try:
branch = get_current_git_branch(swift_repo)
except:
except (OSError, subprocess.CalledProcessError):
branch = None
timestamp = time.strftime("%Y%m%d%H%M%S", time.localtime())
if branch:
Expand All @@ -138,7 +138,7 @@ def log_results(log_directory, driver, formatted_output, swift_repo=None):
driver_name = os.path.basename(driver)
try:
os.makedirs(output_directory)
except:
except OSError:
pass
log_file = os.path.join(output_directory,
driver_name + '-' + timestamp + '.log')
Expand Down
4 changes: 2 additions & 2 deletions benchmark/scripts/Benchmark_RuntimeLeaksRunner.in
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ class LeaksRunnerBenchmarkDriver(perf_test_driver.BenchmarkDriver):
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
p.wait()
error_out = p.stderr.readlines()
except:
except OSError:
print("Child Process Failed! (%s,%s)" % (data['path'], data['test_name']))
return LeaksRunnerResult(test_name, True)

Expand All @@ -94,7 +94,7 @@ class LeaksRunnerBenchmarkDriver(perf_test_driver.BenchmarkDriver):
d['objc_count'] -= FUNC_TO_GLOBAL_COUNTS[data['test_name']]['objc_count']

return LeaksRunnerResult(test_name, (d['objc_count'] + d['swift_count']) > 0)
except:
except (KeyError, ValueError):
print "Failed parse output! (%s,%s)" % (data['path'], data['test_name'])
return LeaksRunnerResult(test_name, True)

Expand Down
2 changes: 1 addition & 1 deletion benchmark/scripts/compare_perf_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
def parse_int(word):
try:
return int(word)
except:
except ValueError:
raise Exception("Expected integer value, not " + word)

def get_scores(fname):
Expand Down
2 changes: 1 addition & 1 deletion tools/SourceKit/bindings/python/sourcekitd/capi.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ def __init__(self, wrapped):
self.wrapped = wrapped
try:
self.__doc__ = wrapped.__doc__
except:
except AttributeError:
pass

def __get__(self, instance, instance_type=None):
Expand Down
2 changes: 1 addition & 1 deletion utils/submit-benchmark-results
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ def submit_results_to_server(results_data, submit_url):
# The result is expected to be a JSON object.
try:
return json.loads(result_data)
except:
except ValueError:
import traceback
print("Unable to load result, not a valid JSON object.")
print()
Expand Down